Bläddra i källkod

LightScatteringFilter : changed the way lightdensity attenuation is computed according to this thread
http://hub.jmonkeyengine.org/forum/topic/light-scattering/#post-207641
Chose the second proposition.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@11054 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

rem..om 11 år sedan
förälder
incheckning
8e65f333d8

+ 4 - 1
jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java

@@ -37,6 +37,7 @@ import com.jme3.export.JmeExporter;
 import com.jme3.export.JmeImporter;
 import com.jme3.export.OutputCapsule;
 import com.jme3.material.Material;
+import com.jme3.math.FastMath;
 import com.jme3.math.Vector3f;
 import com.jme3.post.Filter;
 import com.jme3.renderer.Camera;
@@ -102,7 +103,9 @@ public class LightScatteringFilter extends Filter {
         getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
         viewPort.getCamera().getViewMatrix().mult(lightPosition, viewLightPos);        
         if (adaptative) {
-            innerLightDensity = Math.max(lightDensity - Math.max(screenLightPos.x, screenLightPos.y), 0.0f);
+            float densityX = 1f - FastMath.clamp(FastMath.abs(screenLightPos.x - 0.5f), 0, 1);
+            float densityY = 1f - FastMath.clamp(FastMath.abs(screenLightPos.y - 0.5f), 0, 1);
+            innerLightDensity = lightDensity * densityX * densityY;
         } else {
             innerLightDensity = lightDensity;
         }