diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-07-19 08:06:51 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-07-19 08:19:50 +0200 |
commit | abc38b8d66360060296d792a8cf65c33c6010e8a (patch) | |
tree | bf453034e7d5f42393e24e1b9c66a7a991eb7346 /scene/main | |
parent | b76dfde329592ecfd6f6b952082ae21859039e67 (diff) |
Use C++11 raw literals for shader code to improve readability
In files that have lots of branching, `\t` was replaced with a
tab character instead.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/canvas_item.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index f81a3ef630..c3fd62640a 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -128,24 +128,21 @@ void CanvasItemMaterial::_update_shader() { if (particles_animation) { code += "uniform int particles_anim_h_frames;\n"; code += "uniform int particles_anim_v_frames;\n"; - code += "uniform bool particles_anim_loop;\n"; + code += "uniform bool particles_anim_loop;\n\n"; code += "void vertex() {\n"; - - 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 += "\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) {\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"; + code += " float h_frames = float(particles_anim_h_frames);\n"; + code += " float v_frames = float(particles_anim_v_frames);\n"; + code += " VERTEX.xy /= vec2(h_frames, v_frames);\n"; + code += " float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; + code += " float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; + code += " if (!particles_anim_loop) {\n"; + code += " particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n"; + code += " } else {\n"; + code += " particle_frame = mod(particle_frame, particle_total_frames);\n"; + code += " }"; + code += " UV /= vec2(h_frames, v_frames);\n"; + code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; code += "}\n"; } |