diff options
author | clayjohn <claynjohn@gmail.com> | 2024-09-20 17:43:33 -0700 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-10-17 09:49:49 -0400 |
commit | f922687d3a5697323275dae4614d8e989ef45924 (patch) | |
tree | 54a88bd2d69a8f949e2ed273505be8d74e4fcc51 /servers | |
parent | fe04f5ff9bf3775a15e448794024b4aa44c2c2dc (diff) | |
download | redot-engine-f922687d3a5697323275dae4614d8e989ef45924.tar.gz |
Calculate pixel snap in canvas space instead of world space
This ensures that you are actually snapping to pixels in the viewport and not an arbitrary amount
(cherry picked from commit godotengine/godot@e75900e1ad1a2c699829335ad3be27b4e01afec1)
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/canvas.glsl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/shaders/canvas.glsl b/servers/rendering/renderer_rd/shaders/canvas.glsl index 4426d9eb66..3b86386fc9 100644 --- a/servers/rendering/renderer_rd/shaders/canvas.glsl +++ b/servers/rendering/renderer_rd/shaders/canvas.glsl @@ -214,6 +214,8 @@ void main() { color_interp = color; + vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy; + if (canvas_data.use_pixel_snap) { vertex = floor(vertex + 0.5); // precision issue on some hardware creates artifacts within texture @@ -221,8 +223,6 @@ void main() { uv += 1e-5; } - vertex = (canvas_data.canvas_transform * vec4(vertex, 0.0, 1.0)).xy; - vertex_interp = vertex; uv_interp = uv; |