diff options
| author | krolxon <krolyxon@tutanota.com> | 2026-01-11 19:18:06 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2026-01-11 19:18:06 +0530 |
| commit | ea8f17368def0b581efcc332d057c0a034d4da9b (patch) | |
| tree | 5fd0bfd6627d34b93090d79628bdd87793e9f715 /.config/hypr/shaders/12_posterization.glsl | |
| parent | 4c31a041975718cc2fb933012a303cf457475ce7 (diff) | |
add shader script and keybinds
Diffstat (limited to '.config/hypr/shaders/12_posterization.glsl')
| -rwxr-xr-x | .config/hypr/shaders/12_posterization.glsl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/.config/hypr/shaders/12_posterization.glsl b/.config/hypr/shaders/12_posterization.glsl new file mode 100755 index 0000000..e2391e2 --- /dev/null +++ b/.config/hypr/shaders/12_posterization.glsl @@ -0,0 +1,39 @@ +#version 300 es +// Posterization Shader - OPTIMIZED +// Fixes: Proper rounding, optional dithering to reduce banding + +precision highp float; + +in vec2 v_texcoord; +uniform sampler2D tex; +out vec4 fragColor; + +// --- CONFIGURATION --- +const float COLOR_LEVELS = 4.0; +// Enable dithering to reduce visible banding +const bool DITHER = true; + +// Simple dither pattern +float dither(vec2 pos) { + // 4x4 Bayer matrix approximation + vec2 p = fract(pos * 0.5); + float d = fract(dot(p, vec2(0.75, 0.5))); + return (d - 0.5) / COLOR_LEVELS; +} + +void main() { + vec4 color = texture(tex, v_texcoord); + + vec3 posterized; + if (DITHER) { + // Add dither noise before quantization + float ditherValue = dither(gl_FragCoord.xy); + posterized = floor((color.rgb + ditherValue) * COLOR_LEVELS + 0.5) / COLOR_LEVELS; + } else { + // FIXED: Use round() behavior instead of floor() for better color accuracy + posterized = floor(color.rgb * COLOR_LEVELS + 0.5) / COLOR_LEVELS; + } + + posterized = clamp(posterized, 0.0, 1.0); + fragColor = vec4(posterized, color.a); +} |
