What I'm trying to do is have a light turn a transparent object into a solid one. I can do this just fine with "normal" lights, but I want to do this for a specific light source, which I identify by giving it a color of solid black (0, 0, 0). For this light, for whatever reason it's not working out.
Below is a part of my code, simplified:
void fragment() {
[unrelated code]
.
.
.
ALPHA = 0.0;
}
void light() {
if(LIGHT_COLOR == vec3(0.0, 0.0, 0.0)) {
DIFFUSE_LIGHT += dot(NORMAL, LIGHT) * ATTENUATION * vec3(1.0, 1.0, 1.0) / PI;
ALPHA = 1.0;
} else {
DIFFUSE_LIGHT += clamp(dot(NORMAL, LIGHT), 0.0, 1.0) * ATTENUATION * LIGHT_COLOR / PI;
ALPHA = 1.0;
}
}
In light(), I check whether the light color is solid black to identify the special light, after which I do some operations which include changing the diffuse and alpha. If the light is not special, then I enter the else part, where I compute the lighting differently.
I know for a fact that the if/else can go both ways, since I see the lighting effects of both DIFFUSE_LIGHT statements. Yet for whatever reason, only the ALPHA assignment in the else statement ever works. For the other one, setting it to 0, 1 or any other in-between value, everything looks the same, as in as if the assignment was never there to begin with. What's going on here?