summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2024-09-20 17:43:33 -0700
committerSpartan322 <Megacake1234@gmail.com>2024-10-17 09:49:49 -0400
commitf922687d3a5697323275dae4614d8e989ef45924 (patch)
tree54a88bd2d69a8f949e2ed273505be8d74e4fcc51 /servers
parentfe04f5ff9bf3775a15e448794024b4aa44c2c2dc (diff)
downloadredot-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.glsl4
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;