summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-05 16:26:36 +0200
committerGitHub <noreply@github.com>2021-10-05 16:26:36 +0200
commit198b49d8b589e88a5ae61fc8418ebf8890d2d1f7 (patch)
treecf4a7ef34229d1d40da15655199f863cd5d92c8e
parent3ae1d2d899d1cb2a5e746cbac279a175b22e58f0 (diff)
parenta238dc8bbe1311cc318656408ecbe83895b35924 (diff)
Merge pull request #53237 from metinc/fix-animated-sprite-precision-error-master
-rw-r--r--scene/resources/canvas_item_material.cpp2
-rw-r--r--scene/resources/material.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp
index fa95ab0e79..b291724c4c 100644
--- a/scene/resources/canvas_item_material.cpp
+++ b/scene/resources/canvas_item_material.cpp
@@ -135,7 +135,7 @@ void CanvasItemMaterial::_update_shader() {
code += " particle_frame = mod(particle_frame, particle_total_frames);\n";
code += " }";
code += " UV /= vec2(h_frames, v_frames);\n";
- code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
+ code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n";
code += "}\n";
}
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 66f04f0292..abb3381c4e 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -811,7 +811,7 @@ void BaseMaterial3D::_update_shader() {
code += " particle_frame = mod(particle_frame, particle_total_frames);\n";
code += " }";
code += " UV /= vec2(h_frames, v_frames);\n";
- code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
+ code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n";
} break;
case BILLBOARD_MAX:
break; // Internal value, skip.