#ifdef GL_ES precision mediump int; precision mediump float; #endif #define USE_OGRE_FROM_FUTURE #include SAMPLER2D(inRTT, 0); SAMPLER2D(inBloom, 1); SAMPLER2D(inLum, 2); SAMPLER2D(inKey, 3); #include OGRE_UNIFORMS( uniform float effectAmount; uniform float blurAmount; uniform float gamma; ) vec4 radial(sampler2D tex, vec2 texcoord, int samples, float startScale, float scaleMul, vec4 lum, vec4 key) { vec4 c = vec4(0.0, 0.0, 0.0, 0.0); float scale = startScale; for(int i=0; i < samples; i++) { vec2 uv = ((texcoord - vec2_splat(0.5)) * vec2_splat(scale)) + vec2_splat(0.5); vec4 s = toneMap(texture2D(tex, uv), lum, key); c += s; scale *= scaleMul; } c /= vec4_splat(samples); return c; } MAIN_PARAMETERS IN(vec2 oUv0, TEXCOORD0) MAIN_DECLARATION { // Get main scene colour vec4 sceneCol = texture2D(inRTT, oUv0); // Get luminence value vec4 lum = texture2D(inLum, vec2(0.5, 0.5)); // Get key vec4 key = texture2D(inKey, vec2(0.5, 0.5)); // tone map this vec4 toneMappedSceneCol = toneMap(sceneCol, lum, key); // Get bloom colour vec4 toneMappedBloom = toneMap(texture2D(inBloom, oUv0), lum, key); vec4 effect = radial(inBloom, oUv0, 30, 1.0, 0.95, lum, key); vec4 c = mix(toneMappedSceneCol, toneMappedBloom, blurAmount); c += c * vec4_splat(1.0 - effectAmount); c += effect * vec4_splat(effectAmount); // gamma correction c.rgb = pow(c.rgb, vec3_splat(gamma)); gl_FragColor = c; }