// Text and painted patches over the picture, in the style of the ink pass: // letters boil a little with the animation clock, patches are paper with // ragged, boiling edges and an ink rim. in vec2 UV; out vec4 FragColor; uniform sampler2D tex; uniform vec4 textColor; // rgb + opacity uniform int mode; // 0 = text, 1 = painted patch uniform vec2 rectSize; // pixels uniform float boilTime; uniform float rim; // patch: how much ink around its edge const vec3 INK = vec3(0.10, 0.07, 0.14); void main() { vec2 px = UV * rectSize; if (mode == 0) { // Hand-lettered: the strokes tremble a little, stepped like the drawings vec2 wobble = (vec2(valueNoise(vec3(px * 0.09, boilTime * 3.0)), valueNoise(vec3(px * 0.09 + 17.0, boilTime * 3.0))) - 0.5) * 1.3; float a = texture(tex, UV + wobble / rectSize).a; FragColor = vec4(textColor.rgb, a * textColor.a); return; } float edge = min(min(px.x, rectSize.x - px.x), min(px.y, rectSize.y - px.y)); float rag = (valueNoise(vec3(px * 0.06, boilTime * 2.0)) - 0.5) * 5.0; float shape = smoothstep(0.0, 1.5, edge + rag); float grain = fbm3(vec3(px * 0.025, 3.0)); vec3 color = textColor.rgb * (0.86 + 0.28 * grain); float line = 1.0 - smoothstep(1.2, 3.0, edge + rag * 0.6); color = mix(color, INK, line * rim); FragColor = vec4(color, shape * textColor.a); }