Lighting.glsllib: Use quadratic spotlight falloff in SRGB mode

experimental
shadowislord 10 years ago
parent 19338deaf8
commit 414e1b3fff
  1. 10
      jme3-core/src/main/resources/Common/ShaderLib/Lighting.glsllib

@ -30,6 +30,14 @@ float computeSpotFalloff(in vec4 lightDirection, in vec3 lightVector){
float innerAngleCos = floor(lightDirection.w) * 0.001;
float outerAngleCos = fract(lightDirection.w);
float innerMinusOuter = innerAngleCos - outerAngleCos;
return clamp((curAngleCos - outerAngleCos) / innerMinusOuter, step(lightDirection.w, 0.001), 1.0);
float falloff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, step(lightDirection.w, 0.001), 1.0);
#ifdef SRGB
// Use quadratic falloff (notice the ^4)
return pow(clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0), 4.0);
#else
// Use linear falloff
return falloff;
#endif
}

Loading…
Cancel
Save