Skip to content

Commit

Permalink
Merge pull request #23716 from JFonS/fix_2d_particles_scale
Browse files Browse the repository at this point in the history
Fix Particles2D animation regression from #23702
  • Loading branch information
reduz authored Nov 15, 2018
2 parents 14cf450 + 1267f92 commit 89a8f93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scene/2d/canvas_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
}
Expand Down

0 comments on commit 89a8f93

Please sign in to comment.