#ifdef GL_ES precision mediump int; precision highp float; #endif #define USE_OGRE_FROM_FUTURE #include SAMPLER2D(uDepthMap, 0); SAMPLER2D(uCookieMap, 1); SAMPLER2D(uNoiseMap, 2); OGRE_UNIFORMS( uniform vec4 uAttenuation; uniform vec3 uLightPosition; uniform float uLightFarClipDistance; uniform vec4 uLightColor; uniform float Time; ) MAIN_PARAMETERS IN(vec3 oPos, TEXCOORD0) IN(vec4 oUv, TEXCOORD1) IN(vec2 orUv, TEXCOORD2) MAIN_DECLARATION { vec2 dUV = oUv.xy / vec2_splat(mix(0.0, 1.0, oUv.w)) + vec2_splat(0.001); float depth = texture2D(uDepthMap, dUV).r; float dist = length(oPos - uLightPosition) / uLightFarClipDistance; float rdist = length(oPos - uLightPosition) / uAttenuation.x; if (depth < dist) { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); } else { vec4 cookie = texture2D(uCookieMap, orUv); vec2 noise = vec2(texture2D(uNoiseMap, orUv - vec2_splat(Time * 0.0225)).r, texture2D(uNoiseMap, orUv + vec2_splat(Time * 0.0225)).g); float noisef = noise.x * noise.y; float atten = 1.0 / (uAttenuation.y + uAttenuation.z * rdist + uAttenuation.w * rdist * rdist); gl_FragColor = uLightColor * vec4(cookie.xyz * vec3_splat(cookie.a * atten * noisef), 1.0); } }