From 1267f92740059a3493d43c6104c2993bcaa1f240 Mon Sep 17 00:00:00 2001 From: JFonS Date: Thu, 15 Nov 2018 09:22:11 +0100 Subject: [PATCH] Fix Particles2D animation regression from #23702 --- scene/2d/canvas_item.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 26ad3d0cdd0..6056a7f76f3 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"; }