F
Feral
Guest
Hey everyone,
This is my very first post here. I'm having some issues with an outline shader i'm trying to use.
I first tried this guy's code:
but it didn't work (no outline at all: just my sprite).
Then, I found this topic: https://forum.yoyogames.com/index.php?threads/solved-problem-with-outline-shader.16721/ and tried to write my own shader by fusing pieces of code from the video and from this topic.
So, here's the beast:
Shader fragment:
Create event:
Draw event:
Here's the sprite i'm using:
And finally the result I get with my shader:
I first thought it was due to the collision mask:
but switching the Bounding Box to "Full Image" didn't correct the problem.
What did I do wrong?
GM Version: 1.4.1763
Thanks for reading,
Feral
This is my very first post here. I'm having some issues with an outline shader i'm trying to use.
I first tried this guy's code:
Then, I found this topic: https://forum.yoyogames.com/index.php?threads/solved-problem-with-outline-shader.16721/ and tried to write my own shader by fusing pieces of code from the video and from this topic.
So, here's the beast:
Shader fragment:
Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 sprite_size;
void main()
{
vec2 offsetx;
vec2 offsety;
offsetx.x = sprite_size.x;
offsety.y = sprite_size.y;
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;
}
Code:
sprite_scale = shader_get_uniform(shd_black_outline, "sprite_size");
tex = sprite_get_texture(sprite_index,image_index);
tex_h = texture_get_texel_height(tex);
tex_w = texture_get_texel_width(tex);
Code:
shader_set(shd_black_outline);
shader_set_uniform_f(sprite_scale, tex_w, tex_h);
draw_self();
shader_reset();
And finally the result I get with my shader:
I first thought it was due to the collision mask:
but switching the Bounding Box to "Full Image" didn't correct the problem.
What did I do wrong?
GM Version: 1.4.1763
Thanks for reading,
Feral
Attachments
-
756 bytes Views: 0