test2d.fs (752B)
1 uniform sampler2D uTexture0; 2 uniform sampler2D uTexture1; 3 4 varying vec4 vTexCoord; // u, v, cx, cy 5 6 //varying float vChar; 7 8 // width and height of the "character buffer" 9 const float cbw = 32.0; 10 const float cbh = 32.0; 11 12 // cell count (h & v) for character map 13 const float cc = 16.0; 14 15 void main() { 16 vec2 base, offset; 17 float ch; 18 19 // look up characer in cbw x cbh character buffer texture 20 ch = texture2D(uTexture1, vec2(vTexCoord.z / cbw, vTexCoord.w / cbh)).a 21 * 255.0 + 0.001953125; 22 //ch = vChar; 23 24 // base texcoord of ch (0..255) in cc x cc character map texture 25 base = vec2(fract(ch / cc), -floor(ch / cc) / cc); 26 27 // scale offset texcoord 28 offset = vTexCoord.xy / cc; 29 30 gl_FragColor = texture2D(uTexture0, base + offset * vec2(1.0,-1.0)); 31 } 32