Răsfoiți Sursa

Lighting GLSL library: use inverse square falloff for lighting in sRGB mode
- It is a slightly modified equation that actually terminates the light's influence at the light radius

shadowislord 10 ani în urmă
părinte
comite
9d715cdd2b

+ 5 - 0
jme3-core/src/main/resources/Common/ShaderLib/Lighting.glsllib

@@ -11,7 +11,12 @@ void lightComputeDir(in vec3 worldPos, in float ligthType, in vec4 position, out
     vec3 tempVec = position.xyz * sign(posLight - 0.5) - (worldPos * posLight);
     lightVec = tempVec;          
     float dist = length(tempVec);
+#ifdef SRGB
+    lightDir.w = (1.0 - position.w * dist) / (1.0 + position.w * dist * dist);
+    lightDir.w = clamp(lightDir.w, 0.0, 1.0);
+#else
     lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0);
+#endif
     lightDir.xyz = tempVec / vec3(dist);
 }