nuclear@0: uniform sampler2D framebuf, dither_tex; nuclear@0: uniform int dither_levels, dither_size; nuclear@0: nuclear@0: void main() nuclear@0: { nuclear@0: float levels = float(dither_levels); nuclear@0: nuclear@0: vec4 pixel = texture2D(framebuf, gl_TexCoord[0].xy); nuclear@0: float lum = dot(pixel.xyz, vec3(0.2126, 0.7152, 0.0722)); nuclear@0: float coord_shift = floor(lum * levels) / levels; nuclear@0: nuclear@0: vec2 dsz2 = vec2(float(dither_size), float(dither_size)); nuclear@0: nuclear@0: vec2 coord = mod(gl_FragCoord.xy, dsz2) / float(dither_size); nuclear@0: coord.y = coord.y / levels + coord_shift; nuclear@0: float val = texture2D(dither_tex, coord).x; nuclear@0: nuclear@0: const vec3 dark_col = vec3(0.043, 0.286, 0.337); nuclear@0: const vec3 bright_col = vec3(0.965, 0.778, 0.555); nuclear@0: nuclear@0: gl_FragColor = vec4(mix(dark_col, bright_col, val), 1.0); nuclear@0: }