Odolwa
Member
I have just watched a video Shaun Spaulding posted on applying a black outline to in-game sprites, but I've not been able to implement it. Can anyone help? Here's his code:
Fragment Shader:
And in the player object I put the following:
Create Event:
Draw Event:
Fragment Shader:
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float pixelH;
uniform float pixelW;
void main()
{
vec2 offsetx;
offsetx.x = pixelW;
vec2 offsety;
offsety.y = pixelH;
float alpha = texture2D(gm_BaseTexture, v_vTexcoord).a;
alpha = max(alpha, texture2D(gm_BaseTexture, v_vTexcoord + offsetx).a);
alpha = max(alpha, texture2D(gm_BaseTexture, v_vTexcoord - offsetx).a);
alpha = max(alpha, texture2D(gm_BaseTexture, v_vTexcoord + offsety).a);
alpha = max(alpha, texture2D(gm_BaseTexture, v_vTexcoord - offsety).a);
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor.a = alpha;
}
Create Event:
Code:
//Get 'uniform's for 'shd_outline'
u_ht = shader_get_uniform(shd_outline, "pixelH");
u_width = shader_get_uniform(shd_outline, "pixelW");
Code:
if instance_exists(obj_player)
{
shader_set(shd_outline);
shader_set_uniform_f(u_ht, sprite_height);
shader_set_uniform_f(u_width, sprite_width);
shader_reset();
}