dbf-udg

view sdr/dither.p.glsl @ 9:7056437a361b

added demosys
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 19 Feb 2013 18:17:17 +0200
parents c45c7a1f7d9d
children 5f99c4c7a9fe
line source
1 uniform sampler2D framebuf, dither_tex;
2 uniform int dither_levels, dither_size;
4 void main()
5 {
6 float levels = float(dither_levels);
8 vec4 pixel = texture2D(framebuf, gl_TexCoord[0].xy);
9 float lum = dot(pixel.xyz, vec3(0.2126, 0.7152, 0.0722));
10 float coord_shift = floor(lum * levels) / levels;
12 vec2 dsz2 = vec2(float(dither_size), float(dither_size));
14 vec2 coord = mod(gl_FragCoord.xy, dsz2) / float(dither_size);
15 coord.y = coord.y / levels + coord_shift;
16 float val = texture2D(dither_tex, coord).x;
18 const vec3 dark_col = vec3(0.043, 0.286, 0.337);
19 const vec3 bright_col = vec3(0.965, 0.778, 0.555);
21 gl_FragColor = vec4(mix(dark_col, bright_col, val), 1.0);
22 }