#version 410 uniform sampler2D fontTexture; uniform sampler2D termTexture; uniform vec2 termSize; in vec3 colV; in vec3 worldPos; in vec2 uvV; // 0..1 across the terminal window out vec4 fragColor; vec3 mf(vec3 x) { return x - floor(x); } void main (void) { vec2 uv = uvV.xy; // termTexture has the character data as ascii/255 in red, termSize grid uv.y = 1.0 - uv.y; uv *= termSize; vec2 charPart = fract(uv); uv = (floor(uv) + vec2(0.5, 0.5)) / termSize; float charF = texture(termTexture, uv).r; charF *= 255.0; // textureFont is a 16 x 6 of char pictures, 0x20..0x7f float charLeft = mod(charF , 16.0) / 16.0; float charWidth = 1.0 / 16.0; float charTop = float(floor(charF / 16.0) - 2.0) / 6.0; float charHeight = 1.0 / 6.0; vec2 charSpot = vec2(charLeft, charTop) + charPart * vec2(charWidth, charHeight); float charVal = texture(fontTexture, charSpot).r; charVal = 1.0 - charVal; vec4 c = vec4(charVal, charVal, charVal, charVal * 3.0); c = max(c, vec4(.1,.1,.5,.5)); if(charF < 1.0) discard; fragColor = c; }