1 #import "Common/ShaderLib/MultiSample.glsllib" 2 3 uniform COLORTEXTURE m_Texture; 4 uniform DEPTHTEXTURE m_DepthTexture; 5 6 uniform int m_NbSamples; 7 uniform float m_BlurStart; 8 uniform float m_BlurWidth; 9 uniform float m_LightDensity; 10 uniform bool m_Display; 11 12 in vec2 lightPos; 13 in vec2 texCoord; 14 15 void main(void) 16 { 17 if(m_Display){ 18 19 vec4 colorRes= getColor(m_Texture,texCoord); 20 float factor=(m_BlurWidth/float(m_NbSamples-1.0)); 21 float scale; 22 vec2 texCoo=texCoord-lightPos; 23 vec2 scaledCoord; 24 vec4 res = vec4(0.0); 25 for(int i=0; i<m_NbSamples; i++) { 26 scale = i * factor + m_BlurStart ; 27 scaledCoord=texCoo*scale+lightPos; 28 if(fetchTextureSample(m_DepthTexture, scaledCoord,0).r==1.0){ 29 res += fetchTextureSample(m_Texture,scaledCoord,0); 30 } 31 } 32 res /= m_NbSamples; 33 34 //Blend the original color with the averaged pixels 35 gl_FragColor =mix( colorRes, res, m_LightDensity); 36 }else{ 37 gl_FragColor= getColor(m_Texture,texCoord); 38 } 39 } 40