ソースを参照

GLSL Lighting Lib: fix flickering on directional lights in sRGB mode

shadowislord 10 年 前
コミット
d281920e60

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

@@ -6,14 +6,14 @@
 * lightType should be 0.0,1.0,2.0, repectively for Directional, point and spot lights.
 * Outputs the light direction and the light half vector. 
 */
-void lightComputeDir(in vec3 worldPos, in float ligthType, in vec4 position, out vec4 lightDir, out vec3 lightVec){
-    float posLight = step(0.5, ligthType);    
+void lightComputeDir(in vec3 worldPos, in float lightType, in vec4 position, out vec4 lightDir, out vec3 lightVec){
+    float posLight = step(0.5, lightType);    
     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);
+    lightDir.w = clamp(lightDir.w, 1.0 - posLight, 1.0);
 #else
     lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0);
 #endif