I'm trying to make a shader which changes the color of every pixel to some fixed color while preserving the alpha value.
It should be as simple as this (to set it to green e.g.):
lowp vec4 col=texture2D(fTexture,fTexCoord);
gl_FragColor = vec4(0.0,1.0,0.0,col.a) |
However, the alpha value does not seem to be used, so the whole thing becomes homogenously colored to (0.0,1.0,0.0,1.0).
Is this a bug in gideros or am i doing something wrong? i spent an hour trying to understand what i'm doing wrong, and it seems that maybe nothing.
even the simpler example
gl_FragColor = vec4(0.0,1.0,0.0,0.1) |
outputs all pixels (0.0,1.0,0.0,1.0).
i'm tring it on a windows pc. please help.
Comments
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Note that if you lookup a texture you'll also get an alpha premultiplied sample, since Gideros converts image to that format before uploading them to the GPU.
I can't tell why Gideros uses premultiplied alpha output, but it seems to be a common convention in OpenGL programs.
it is very confusing though for me as it is different from how gideros/lua handles colors.
Fragmenter - animated loop machine and IKONOMIKON - the memory game