Problem with Spine, spinemodel and shaders -- the white edges [SOLVED]

Hello, everyone. I tried to change the color of my spinemodel using shaders, but I have a problem with this white edges:

And in the game:

My images in atlas has (0.79, 0.79, 0.79) color: ( The eyes, mouth, and cheeks are another gameobject, not spinemodel)

My shader:

varying mediump vec2 var_texcoord0;
varying lowp vec4 var_color;

uniform lowp sampler2D texture_sampler;
uniform lowp vec4 tint;

void main()
{
    vec4 texColor=texture2D(texture_sampler, var_texcoord0.xy);
    float epsilon = 0.6;

    if (abs(texColor.r - 0.79) < epsilon && 
        abs(texColor.g - 0.79) < epsilon && 
        abs(texColor.b - 0.79) < epsilon) {
            gl_FragColor = vec4(tint.rgb, texColor.a);
    } else {
            gl_FragColor = texColor;
    }
}

The tint is a material parameter that is set programmatically:

I tried to fix it with the Threshold Alpha tool in GIMP and set it to 0, but the problem persisted. What’s the next thing I should try? What might be the issue?

The problem is the shader separately run for every attachment.

Solution: first render the spine model to a render target without the tint shader, after that you put the rendered result to the screen, here is where you should put the tint shader.

1 Like

Thank you for your answer! I tried to follow your answer but I also had another collection, where can be a lot of spinemodels, so I found another solution – I changed the shader:

varying mediump vec2 var_texcoord0;
uniform lowp sampler2D texture_sampler;
uniform lowp vec4 tint;

void main()
{
    vec4 texColor = texture2D(texture_sampler, var_texcoord0.xy);

    float target_value = 0.79;
    float epsilon = 0.65;

    if (abs(texColor.r - target_value) < epsilon && 
    abs(texColor.g - target_value) < epsilon && 
    abs(texColor.b - target_value) < epsilon) { 
        lowp vec4 final_tint = vec4(tint.rgb * tint.w, tint.w);

        gl_FragColor = vec4(final_tint.rgb * texColor.a, texColor.a);
    } else {
        gl_FragColor = texColor;
    }
}

The result:

4 Likes