summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-11-15 16:29:58 +0100
committerGitHub <noreply@github.com>2018-11-15 16:29:58 +0100
commit89a8f930d4143ed9a65aa1c068b1ec3523f13a6a (patch)
treec81712f8eea1b319cd82fc0ef845ec9a33401565
parent14cf450b0da4102a59d8890d931e38104266d96a (diff)
parent1267f92740059a3493d43c6104c2993bcaa1f240 (diff)
Merge pull request #23716 from JFonS/fix_2d_particles_scale
Fix Particles2D animation regression from #23702
-rw-r--r--scene/2d/canvas_item.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 26ad3d0cdd..6056a7f76f 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -123,6 +123,8 @@ void CanvasItemMaterial::_update_shader() {
code += "\tfloat h_frames = float(particles_anim_h_frames);\n";
code += "\tfloat v_frames = float(particles_anim_v_frames);\n";
+ code += "\tVERTEX.xy /= vec2(h_frames, v_frames);\n";
+
code += "\tint total_frames = particles_anim_h_frames * particles_anim_v_frames;\n";
code += "\tint frame = int(float(total_frames) * INSTANCE_CUSTOM.z);\n";
code += "\tif (particles_anim_loop) {\n";
@@ -134,7 +136,7 @@ void CanvasItemMaterial::_update_shader() {
code += "\tfloat frame_w = 1.0 / h_frames;\n";
code += "\tfloat frame_h = 1.0 / v_frames;\n";
code += "\tUV.x = UV.x * frame_w + frame_w * float(frame % particles_anim_h_frames);\n";
- code += "\tUV.y = UV.y * frame_h + frame_h * float(frame / particles_anim_v_frames);\n";
+ code += "\tUV.y = UV.y * frame_h + frame_h * float(frame / particles_anim_h_frames);\n";
code += "}\n";
}