summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorJFonS <joan.fonssanchez@gmail.com>2019-02-10 01:13:42 +0100
committerJFonS <joan.fonssanchez@gmail.com>2019-02-11 14:56:23 +0100
commit4d933b1530d08b9bfad539f5146a5bb649476645 (patch)
tree7c0bb07fac6fb48bb5f60d03d868b9deeb9c421a /scene/resources
parenta7a21bd9fe72052e117a71f9934b9acae038d962 (diff)
Fix canvas particle material for old GLSL versions
Diffstat (limited to 'scene/resources')
-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;
}