Hello Guest

Author Topic: Weird Shader bug in tk2d?  (Read 3975 times)

Serge

  • Newbie
  • *
  • Posts: 12
    • View Profile
Weird Shader bug in tk2d?
« on: January 31, 2017, 09:16:32 pm »
Hey, i've encountered a weird shader bug in the BlendVertexColor shader.

Reproduction steps:

Have a plain white sprite (255,255,255) with alpha 255. On top of that, display a black sprite (0, 0, 0) with 128 alpha. As a result i would expect a gray tone, 128, 128, 128.
But what i get is a blueish gray tone of 107, 114, 125. (not sure if the blue unity background is shining throught or so)

I had a look into the shader code but couldn't determine whats wrong there.

edit:
Ok i had a look into Unity's own sprite shader and think i found a way to have the shader work properly:

Set Blend to:
Blend One OneMinusSrcAlpha

and

Code: [Select]
fixed4 frag_mult(v2f_vct i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
  col.rgb *= col.a;
return col;
}

seems to deliver the expected results.
« Last Edit: January 31, 2017, 09:36:24 pm by Serge »