I'm trying to calculate the reflection/refraction but with I perform a
gl_FragColor = mix(objectColor, environmentColor, 1.0f);
I start getting uniform errors that it can't find my uniform for lightPosition
. This doesn't make sense as I'm using that uniform for calculating the diffuse lighting and when I remove the mix function to just gl_FragColor = objectColor;
its fine. I'm not sure what I'm doing wrong, if anyone could help out it would be greatly appreciated.
mix(x, y, a)
can be expressed as x*(1.0−a) + y*a
.
The last argument of mix
is a constant. Hence the expression can be optimized by the compiler.
gl_FragColor = mix(objectColor, environmentColor, 1.0f);
is equal to
gl_FragColor = environmentColor;
So objectColor
is not used and therefore lightPosition
is not used either. Hence the uniform lightPosition
is not an active program resource.