summaryrefslogtreecommitdiffstats
path: root/scene/resources/material.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-02-12 11:25:32 +0100
committerGitHub <noreply@github.com>2019-02-12 11:25:32 +0100
commit9c6f19117c85da45349d69a68c581657bed6994b (patch)
treee755f7ac96191cf2e685fd0954e4a4a28d955ec5 /scene/resources/material.cpp
parentc5a526840eef32ec89585afabb5884a03858004e (diff)
parent4d933b1530d08b9bfad539f5146a5bb649476645 (diff)
downloadredot-engine-9c6f19117c85da45349d69a68c581657bed6994b.tar.gz
Merge pull request #25754 from JFonS/fix_25567
Fix canvas particle material for old GLSL versions
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r--scene/resources/material.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 5ffaf41581..619af375da 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -617,11 +617,17 @@ void SpatialMaterial::_update_shader() {
code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat_world;\n";
//handle animation
+ code += "\tfloat h_frames = float(particles_anim_h_frames);\n";
+ code += "\tfloat v_frames = float(particles_anim_v_frames);\n";
code += "\tfloat particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n";
code += "\tfloat particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n";
- code += "\tif (!particles_anim_loop) particle_frame=clamp(particle_frame,0.0,particle_total_frames-1.0); else particle_frame=mod(particle_frame,float(particle_total_frames));\n";
- code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
- code += "\tUV += vec2(mod(particle_frame,float(particles_anim_h_frames)) / float(particles_anim_h_frames), floor(particle_frame / float(particles_anim_h_frames)) / float(particles_anim_v_frames));\n";
+ code += "\tif (!particles_anim_loop) {\n";
+ code += "\t\tparticle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n";
+ code += "\t} else {\n";
+ code += "\t\tparticle_frame = mod(particle_frame, particle_total_frames);\n";
+ code += "\t}";
+ code += "\tUV /= vec2(h_frames, v_frames);\n";
+ code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
} break;
}