Godot Version
4.3
Question
I would like a canvas item shader to make a sprite copy the screen’s texture at its position shifted by some vec2 offset
.
This is what I came up with:
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
uniform vec2 offset = vec2(0.1, 0.1);
void fragment() {
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV+offset);
}
And the screen texture actually gets shifted!
But…
When I zoom the offset changes
And that makes sense because
compared to the image, the offset looks greater if the image appears small on the screen and vice versa the movement appears smaller if the image appears big on the screen
The problem is…
I absolutely got no idea how to fix this
Can anybody help me?
Thanks in advance!