summaryrefslogtreecommitdiff
path: root/smoothCamera.glsl
blob: 074c52ca8604a904d148b87369fbf177443b3d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
}