diff options
| author | cursed22bc <admin@pixeldawn.org> | 2026-02-20 15:23:20 +0200 |
|---|---|---|
| committer | cursed22bc <admin@pixeldawn.org> | 2026-02-20 15:23:20 +0200 |
| commit | 3039593b72a9b64597276ef75b089ea7033bc3c0 (patch) | |
| tree | 42586a25c2b4460c9019aad3e849f1b0363a41b6 /smoothCamera.glsl | |
Diffstat (limited to 'smoothCamera.glsl')
| -rw-r--r-- | smoothCamera.glsl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/smoothCamera.glsl b/smoothCamera.glsl new file mode 100644 index 0000000..074c52c --- /dev/null +++ b/smoothCamera.glsl @@ -0,0 +1,17 @@ +//[[ +// +// applies sub-pixel offset to the viewport texture for smooth camera movement +// while keeping pixel-perfect rendering. +// - game is rendered with camera snapped to integer pixels (pixel-perfect) +// - this shader samples the texture with a UV offset = (smooth_pos - snapped_pos) +// - the offset creates the illusion of smooth camera movement +// +// offset: (subPixelX, subPixelY) in UV space (0-1 range) +// texture must have 1px padding on each side to avoid black bars when sampling. +//]] + +extern vec2 offset; + +vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords) { + return Texel(tex, texture_coords + offset); +} |
