#ifdef GL_ES precision mediump int; precision mediump float; #endif #define USE_OGRE_FROM_FUTURE #include SAMPLER2D(RT, 0); OGRE_UNIFORMS( uniform float NumTiles; uniform float Threshold; ) MAIN_PARAMETERS IN(vec2 oUv0, TEXCOORD0) MAIN_DECLARATION { vec3 EdgeColor = vec3(0.7, 0.7, 0.7); float size = 1.0 / NumTiles; vec2 Pbase = oUv0 - mod(oUv0, vec2_splat(size)); vec2 PCenter = Pbase + vec2_splat(size/2.0); vec2 st = (oUv0 - Pbase) / vec2_splat(size); vec4 c1 = vec4_splat(0.0); vec4 c2 = vec4_splat(0.0); vec4 invOff = vec4((1.0-EdgeColor), 1.0); if (st.x > st.y) { c1 = invOff; } float threshholdB = 1.0 - Threshold; if (st.x > threshholdB) { c2 = c1; } if (st.y > threshholdB) { c2 = c1; } vec4 cBottom = c2; c1 = vec4_splat(0.0); c2 = vec4_splat(0.0); if (st.x > st.y) { c1 = invOff; } if (st.x < Threshold) { c2 = c1; } if (st.y < Threshold) { c2 = c1; } vec4 cTop = c2; vec4 tileColor = texture2D(RT, PCenter); vec4 result = tileColor + cTop - cBottom; gl_FragColor = result; }