Browse Source

* Do not use control flow in GLSL version 1.0 in Lighting.frag

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8170 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
sha..rd 14 years ago
parent
commit
dd7495185c
1 changed files with 17 additions and 9 deletions
  1. 17 9
      engine/src/core-data/Common/MatDefs/Light/Lighting.frag

+ 17 - 9
engine/src/core-data/Common/MatDefs/Light/Lighting.frag

@@ -174,16 +174,21 @@ void main(){
 
 
     #ifndef VERTEX_LIGHTING
     #ifndef VERTEX_LIGHTING
         float spotFallOff = 1.0;
         float spotFallOff = 1.0;
-        if(g_LightDirection.w != 0.0){
-              vec3 L       = normalize(lightVec.xyz);
-              vec3 spotdir = normalize(g_LightDirection.xyz);
-              float curAngleCos = dot(-L, spotdir);             
-              float innerAngleCos = floor(g_LightDirection.w) * 0.001;
-              float outerAngleCos = fract(g_LightDirection.w);
-              float innerMinusOuter = innerAngleCos - outerAngleCos;
 
 
-              spotFallOff = (curAngleCos - outerAngleCos) / innerMinusOuter;
+        #if __VERSION__ >= 110
+          // allow use of control flow
+          if(g_LightDirection.w != 0.0){
+        #endif
 
 
+          vec3 L       = normalize(lightVec.xyz);
+          vec3 spotdir = normalize(g_LightDirection.xyz);
+          float curAngleCos = dot(-L, spotdir);             
+          float innerAngleCos = floor(g_LightDirection.w) * 0.001;
+          float outerAngleCos = fract(g_LightDirection.w);
+          float innerMinusOuter = innerAngleCos - outerAngleCos;
+          spotFallOff = (curAngleCos - outerAngleCos) / innerMinusOuter;
+
+          #if __VERSION__ >= 110
               if(spotFallOff <= 0.0){
               if(spotFallOff <= 0.0){
                   gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;
                   gl_FragColor.rgb = AmbientSum * diffuseColor.rgb;
                   gl_FragColor.a   = alpha;
                   gl_FragColor.a   = alpha;
@@ -191,7 +196,10 @@ void main(){
               }else{
               }else{
                   spotFallOff = clamp(spotFallOff, 0.0, 1.0);
                   spotFallOff = clamp(spotFallOff, 0.0, 1.0);
               }
               }
-        }
+             }
+          #else
+             spotFallOff = clamp(spotFallOff, step(g_LightDirection.w, 0.001), 1.0);
+          #endif
      #endif
      #endif
  
  
     // ***********************
     // ***********************