#Shaders and image_alpha

1 messages · Page 1 of 1 (latest)

dull sand
#

Working on an enhancement of one of my shaders, and I found out, that, when image_alpha is set, the shader renders the original sprite texture almost transparent, like with a 0.5 image_alpha, it seems, 0.5 * 0.5 * 0.5 gets applied or so...

Anything I should know about image alpha and shaders?
I send the image_alpha down to the shader through a uniform, together with the sprite texture but I can't get it to work...

I get the next pixel from the sprite's texture through

vec4  spriteSample  = texture2D(u_sSpriteSurface, v_vSurfaceUV);

and when I simply set

gl_FragColor = spriteSample;

the shader already renders the thing almost fully transparent, like I said, as if a 0.5 alpha gets applied multiple times.

What do I miss?

rare hatch
#

image_alpha is the alpha component of vertex color, which by default gets multiplied by the pixel color in shaders. so, not in your shader here, but normally, you get image_alpha * texture alpha and then that does gm's default alpha blending

#

so if image alpha is 0.5 and the texture alpha is 0.5, in a normal shader you get 0.5 * 0.5 which is a final pixel alpha of .25. that is the source, which is then multiplied (not in the shader, later on) using the blend equation by the destination alpha

#

your shader example is not using vertex color so you would get texture alpha only

#

and then blending

dull sand
#

ooookay ... wait, that explains LOTS