C
Charyb
Guest
So basically I'm trying to imitate the overlay effect that Photoshop has. I'm attempting to overlay a background overtop of my game screen.
Basically the shader appears in the top left corner of the screen and is somewhat smaller than the actual screen size. That red square is the background with the overlay effect, but it's drawing in the top left corner of the screen instead of the entire screen like I want:
shd_overlay fragment:
Game Start Event:
Create Event:
Draw GUI Event:
Not sure why the shader goes to the top left corner of the screen. I've also tried the 'Post Draw' event instead of the 'Draw GUI' event, same thing.
The really strange thing is, if I use another shader: shd_grey which converts the entire texture to greyscale, it covers the screen perfectly. But this shader does not, this shader only covers a portion of the top left corner.
Basically the shader appears in the top left corner of the screen and is somewhat smaller than the actual screen size. That red square is the background with the overlay effect, but it's drawing in the top left corner of the screen instead of the entire screen like I want:
shd_overlay fragment:
Code:
//
// Overlay Shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform sampler2D texOverlay;
void main()
{
vec4 inColor = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord);
vec4 outColor = vec4(0.0, 0.0, 0.0, inColor.a);
vec4 overlay = texture2D(texOverlay, v_vTexcoord);
if (inColor.r > 0.5)
{
outColor.r = (1.0 - (1.0 - 2.0 * (inColor.r - 0.5)) * (1.0 - overlay.r));
}
else
{
outColor.r = ((2.0 * inColor.r) * overlay.r);
}
if (inColor.g > 0.5)
{
outColor.g = (1.0 - (1.0 - 2.0 * (inColor.g - 0.5)) * (1.0 - overlay.g));
}
else
{
outColor.g = ((2.0 * inColor.g) * overlay.g);
}
if (inColor.b > 0.5)
{
outColor.b = (1.0 - (1.0 - 2.0 * (inColor.b - 0.5)) * (1.0 - overlay.b));
}
else
{
outColor.b = ((2.0 * inColor.b) * overlay.b);
}
gl_FragColor = mix(outColor, inColor,1.0 - overlay.a);
}
Code:
application_surface_draw_enable(false);
global.game_width = 640; //this is view_wview[0]
global.game_height = 384; //this is view_hview[0]
global.pref_width = 1280; //this is view_wport[0]
global.pref_height = 768; //this is view_hport[0]
display_set_gui_size(global.pref_width, global.pref_height);
Code:
shader = shd_overlay;
stage = shader_get_sampler_index(shader, "texOverlay");
bgToDrawOver = bg_overlay_test;
bgTex = background_get_texture(bgToDrawOver); //bg width/height: 1280x768
Draw GUI Event:
Code:
shader_set(shader);
texture_set_stage(stage, bgTex);
draw_surface(application_surface,0,0);
shader_reset();
The really strange thing is, if I use another shader: shd_grey which converts the entire texture to greyscale, it covers the screen perfectly. But this shader does not, this shader only covers a portion of the top left corner.
Last edited by a moderator: