added Dither effect

This commit is contained in:
jonathan
2026-02-04 18:31:54 +01:00
parent 0d2830d2f2
commit fb87ccf301
3 changed files with 409 additions and 398 deletions
+10
View File
@@ -5,7 +5,9 @@ uniform int sample_count:hint_range(1, 20) = 1;
uniform float color_steps:hint_range(1.0, 255.0, 1.0);
uniform sampler2D color_curve;
uniform bool dither = false;
const mat4 bayer = (mat4(vec4(0,8,2,10),vec4(12,4,14,6),vec4(3,11,1,9),vec4(15,7,13,5)) -8.) / 16.;
void vertex() {
// Called for every vertex the material is visible on.
@@ -41,12 +43,20 @@ void fragment() {
texture(color_curve,vec2(fullColor.g,0)).g,
texture(color_curve,vec2(fullColor.b,0)).b);
vec3 scaledColor = strechedColor * color_steps;
if(dither){
ivec2 bayerIndex = ivec2(int(mod(float(intUv.x),4.)),int(mod(float(intUv.y),4.)));
float bayerValue = bayer[bayerIndex.x][bayerIndex.y];
scaledColor+=bayerValue;
}
vec3 roundColor = round(scaledColor);
vec3 backScaledColor = roundColor / color_steps;
COLOR = vec4(backScaledColor,1);
//COLOR = vec4(flooredUv,0,1);
//COLOR = vec4(vec3(float(textureQueryLevels(TEXTURE)/1)),1);
//COLOR = vec4(1,0,0,1);
//COLOR = vec4(bayerValue,0,0,1);
}
//void light() {