1#version 100 2 3precision mediump int; 4precision mediump float; 5 6uniform sampler2D RT; 7uniform float NumTiles; 8uniform float Threshold; 9varying vec2 uv0; 10 11void main() 12{ 13 vec3 EdgeColor = vec3(0.7, 0.7, 0.7); 14 15 float size = 1.0/NumTiles; 16 vec2 Pbase = uv0 - mod(uv0, vec2(size)); 17 vec2 PCenter = vec2(Pbase + (size/2.0)); 18 vec2 st = (uv0 - Pbase)/size; 19 vec4 c1 = vec4(0.0); 20 vec4 c2 = vec4(0.0); 21 vec4 invOff = vec4((1.0-EdgeColor),1.0); 22 if (st.x > st.y) { c1 = invOff; } 23 float threshholdB = 1.0 - Threshold; 24 if (st.x > threshholdB) { c2 = c1; } 25 if (st.y > threshholdB) { c2 = c1; } 26 vec4 cBottom = c2; 27 c1 = vec4(0.0); 28 c2 = vec4(0.0); 29 if (st.x > st.y) { c1 = invOff; } 30 if (st.x < Threshold) { c2 = c1; } 31 if (st.y < Threshold) { c2 = c1; } 32 vec4 cTop = c2; 33 vec4 tileColor = vec4(texture2D(RT, PCenter)); 34 vec4 result = tileColor + cTop - cBottom; 35 gl_FragColor = result; 36} 37