From 826900a5d397c5cc8632a7eb58b9b3e5a47e7e45 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Sun, 16 Feb 2014 13:44:22 +0000 Subject: [PATCH] LightScatteringFilter : changed the way the light shafts are blended into the original scene. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11057 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../core-effects/Common/MatDefs/Post/LightScattering.frag | 3 ++- .../Common/MatDefs/Post/LightScattering15.frag | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/src/core-effects/Common/MatDefs/Post/LightScattering.frag b/engine/src/core-effects/Common/MatDefs/Post/LightScattering.frag index 7e1c542f0..bc85142e0 100644 --- a/engine/src/core-effects/Common/MatDefs/Post/LightScattering.frag +++ b/engine/src/core-effects/Common/MatDefs/Post/LightScattering.frag @@ -29,7 +29,8 @@ void main(void) res /= m_NbSamples; //Blend the original color with the averaged pixels - gl_FragColor =mix( colorRes, res, m_LightDensity); + float mean = (res.r + res.g + res.b)/3; + fragColor =mix(colorRes ,mix( colorRes, res, m_LightDensity),mean); }else{ gl_FragColor= texture2D(m_Texture,texCoord); } diff --git a/engine/src/core-effects/Common/MatDefs/Post/LightScattering15.frag b/engine/src/core-effects/Common/MatDefs/Post/LightScattering15.frag index bf72fd9d5..57547ea1a 100644 --- a/engine/src/core-effects/Common/MatDefs/Post/LightScattering15.frag +++ b/engine/src/core-effects/Common/MatDefs/Post/LightScattering15.frag @@ -28,12 +28,13 @@ void main(void) scaledCoord=texCoo*scale + m_LightPosition.xy; if(fetchTextureSample(m_DepthTexture, scaledCoord,0).r==1.0){ res += fetchTextureSample(m_Texture,scaledCoord,0); + } } - } res /= m_NbSamples; - + //Blend the original color with the averaged pixels - fragColor = mix( colorRes, res, m_LightDensity); + float mean = (res.r + res.g + res.b)/3; + fragColor =mix(colorRes ,mix( colorRes, res, m_LightDensity),mean); }else{ fragColor = getColor(m_Texture,texCoord); }