I am using the below shader to try and put transparency on the shadows in my room. There are two main problems with it that I cannot figure out.
So what I am doing is drawing all instances to one surface, then drawing the light mask on another. Then I draw the light mask on top of the instances layer to hide objects that are not in the light. The shader is meant to decrease the alpha value of any black areas so that the player can still see their surroundings.
The issue is, the shader only matches a black pixel when I check for (rgb = 1, 1, 1) when it should be (rgb = 0, 0, 0) to my understanding. Also, the shader is applying transparency to my objects (which are flat red with black details) which is even more confusing because red shouldnt match all zeros or all ones for color value.
I've been playing around with this for a while now, but I can't figure out what it is doing. Even if I remove the lighting mask and just draw the objects, they still are drawn partially transparent even though they shouldn't match the color specified in my IF statement.
Any ideas what might be going on here?
So what I am doing is drawing all instances to one surface, then drawing the light mask on another. Then I draw the light mask on top of the instances layer to hide objects that are not in the light. The shader is meant to decrease the alpha value of any black areas so that the player can still see their surroundings.
The issue is, the shader only matches a black pixel when I check for (rgb = 1, 1, 1) when it should be (rgb = 0, 0, 0) to my understanding. Also, the shader is applying transparency to my objects (which are flat red with black details) which is even more confusing because red shouldnt match all zeros or all ones for color value.
I've been playing around with this for a while now, but I can't figure out what it is doing. Even if I remove the lighting mask and just draw the objects, they still are drawn partially transparent even though they shouldn't match the color specified in my IF statement.
Any ideas what might be going on here?
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
vec4 fColor;
void main()
{
fColor.r = v_vColour.r;
fColor.g = v_vColour.g;
fColor.b = v_vColour.b;
if(fColor.r == 1.0 && fColor.g == 1.0 && fColor.b == 1.0){
fColor.a = 0.2;
}
else{
fColor.a = 1.0;
}
gl_FragColor = fColor * texture2D( gm_BaseTexture, v_vTexcoord );
}