Преглед изворни кода

Lighting.glsllib: Use quadratic spotlight falloff in SRGB mode

shadowislord пре 10 година
родитељ
комит
414e1b3fff
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      jme3-core/src/main/resources/Common/ShaderLib/Lighting.glsllib

+ 9 - 1
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
 }