• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders Simple shading shader help

gotad

Member
Hey guys!
I've been trying to get my simple character shading shader working properly for my game, but I know nothing about building said shaders myself.
Here's what I'm dealing with:

GML:
varying vec2 v_vTexcoord;

varying vec4 v_vColour;

void main() {
    vec2 offset = vec2(0.005,0.0);
    vec3 shade_color = vec3(0,0,0);

    float mix_amount = ceil( texture2D( gm_BaseTexture, v_vTexcoord + offset ).a );
    vec4 base_color = (v_vColour * texture2D( gm_BaseTexture, v_vTexcoord ));
    gl_FragColor = vec4( mix(base_color.rgb, shade_color, (1.0 - mix_amount) * 0.25), base_color.a );

}
The goal is to simply draw a darker portion of the character on the side of the sprite, like this:
shaderbros.png

But, here's the issue:


As you can see, some characters have trouble drawing their shader because of their outlines. The right brim of the mage hat's outline tricks the shader into not drawing fully, since it doesn't ignore the black outline.
How might I make the shader ignore the black outline when navigating the sprite? Or, simply ignore the color black entirely. Here's another example of the problem:
crabshader.png
You can see bits near his legs that are getting clumpy thanks to this outline.

Any help would be appreciated! Thanks in advance guys
 

Attachments

Top