summaryrefslogtreecommitdiff
path: root/smoothCamera.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'smoothCamera.glsl')
-rw-r--r--smoothCamera.glsl17
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);
+}