Krolyxon
Commit 57dab0a

Branches

Refs →

aurora.confighyprshaders09_pixelated.glsl

28 lines · 878 B · GLSL

1#version 300 es
2// Pixelation Shader - OPTIMIZED
3// Fixes: Sample from pixel CENTER (not corner), aspect ratio support
4
5precision highp float;
6
7in vec2 v_texcoord;
8uniform sampler2D tex;
9out vec4 fragColor;
10
11// --- CONFIGURATION ---
12// Pixels across the shorter dimension (height usually)
13const float PIXEL_COUNT = 350.0;
14// Set to your aspect ratio, or 1.0 for square pixels
15const float ASPECT_RATIO = 16.0 / 9.0;
16
17void main() {
18 // Calculate pixel dimensions accounting for aspect ratio
19 vec2 pixelCount = vec2(PIXEL_COUNT * ASPECT_RATIO, PIXEL_COUNT);
20 vec2 pixelSize = 1.0 / pixelCount;
21
22 // FIXED: Sample from pixel CENTER, not corner
23 // This prevents the "swimming" artifact when content moves
24 vec2 pixelCoord = floor(v_texcoord * pixelCount) + 0.5;
25 vec2 sampleCoord = pixelCoord / pixelCount;
26
27 fragColor = texture(tex, sampleCoord);
28}