From 8e65f333d80489a118d7d78ef9cd48217da7f058 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Sun, 16 Feb 2014 13:42:25 +0000 Subject: [PATCH] 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 --- .../java/com/jme3/post/filters/LightScatteringFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java index 20e5e3397..271358454 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java +++ b/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; }