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