t0neg0d wrote:Alpha masks are usually a second image passed into a shader and blended like:
- Code: Select all
vec4 c = texture2D(colorTexture, texCoords0);
c.a *= texture2D(maskTexture, texCoords0).r;
gl_FragColor = c;
The mask image uses black (0.0... i.e. alphaValue * 0.0 = 0.0 or transparent) for complete transparency, white (1.0... i.e. alphaValue * 1.0 = the original alphaValue) for completely opaque (or original opacity anyways), and shades of gray for values in between.
Do you mind explaining to me how to use "texCoords0" and "gl_FragColor"? It seems that the problem with the implementation that I wanted to use is that opengl is really really picky about destination alpha values. I seem to not be able to make it recognize them (in the way I was trying before). I'd probably have to switch to doing something like this, but I've never used a "texCoords0", nor "gl_FragColor".
For example, If I look at some shader code examples online, they all declare those varibles with "attribute _________" or "varying texCoords0". Isn't that syntax c++? :S As you can tell, I'm very very new at shaders. What is the java equivalent of the setup for this?