You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
OF_GLSL_SHADER_HEADER
|
|
precision mediump float;
|
|
|
|
uniform sampler2DRect tex0; // Main texture
|
|
uniform sampler2D tex1; // Bayer texture
|
|
uniform vec2 resolution;
|
|
uniform float time;
|
|
uniform int frame;
|
|
|
|
in vec2 varyingtexcoord;
|
|
out vec4 fragColor;
|
|
|
|
const float SIZE = 256.0;
|
|
|
|
const mat4 ditherMatrix = mat4(
|
|
1.0/17.0, 9.0/17.0, 3.0/17.0, 11.0/17.0,
|
|
13.0/17.0, 5.0/17.0, 15.0/17.0, 7.0/17.0,
|
|
4.0/17.0, 12.0/17.0, 2.0/17.0, 10.0/17.0,
|
|
16.0/17.0, 8.0/17.0, 14.0/17.0, 6.0/17.0
|
|
);
|
|
|
|
void main() {
|
|
vec2 uv = varyingtexcoord / resolution;
|
|
vec4 texColor = texture(tex0, varyingtexcoord);
|
|
vec3 t = texColor.rgb;
|
|
|
|
vec2 fragCoord = gl_FragCoord.xy;
|
|
|
|
// color to display, use floating point precision here
|
|
vec3 col = t;
|
|
|
|
// Sample the Bayer 8x8 texture for the dither pattern
|
|
float ditherValue = texture(tex1, fragCoord / 8.0).r;
|
|
|
|
// Apply dithering with increased effect
|
|
col += (ditherValue - 0.5) / 2.0 * 2.0;
|
|
|
|
// Quantize the color
|
|
col = (floor(col * 8.0) + 0.5) / 8.0;
|
|
|
|
fragColor = vec4(col, texColor.a);
|
|
}
|