Compare fragLightVec square to LightCutoffSquareRadius

This commit is contained in:
Zach Pomerantz 2016-02-17 12:49:41 -08:00
parent 84f810bdc0
commit bab29a0d3e
3 changed files with 6 additions and 2 deletions

View file

@ -53,6 +53,10 @@ float getLightCutoffRadius(Light l) {
return l._attenuation.y;
}
float getLightCutoffSquareRadius(Light l) {
return getLightCutoffRadius(l) * getLightCutoffRadius(l);
}
float getLightCutoffIntensity(Light l) {
return l._attenuation.z;
}

View file

@ -48,7 +48,7 @@ void main(void) {
vec3 fragLightVec = getLightPosition(light) - fragPos.xyz;
// Kill if too far from the light center
if (dot(fragLightVec, fragLightVec) > getLightCutoffRadius(light)) {
if (dot(fragLightVec, fragLightVec) > getLightCutoffSquareRadius(light)) {
discard;
}

View file

@ -47,7 +47,7 @@ void main(void) {
vec3 fragLightVec = getLightPosition(light) - fragPos.xyz;
// Kill if too far from the light center
if (dot(fragLightVec, fragLightVec) > getLightCutoffRadius(light)) {
if (dot(fragLightVec, fragLightVec) > getLightCutoffSquareRadius(light)) {
discard;
}