Skip to content

Commit

Permalink
Merge pull request #78021 from clayjohn/Particles-size-rot-reset
Browse files Browse the repository at this point in the history
Correctly reset particle size and rotation in ParticlesProcessMaterial
  • Loading branch information
akien-mga committed Jun 9, 2023
2 parents fd2f339 + 353a4e1 commit 082cfd5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scene/resources/particle_process_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,20 @@ void ParticleProcessMaterial::_update_shader() {
code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle
code += " CUSTOM.y = 0.0;\n"; // phase
code += " CUSTOM.w = (1.0 - lifetime_randomness * rand_from_seed(alt_seed));\n";
code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, anim_offset_rand);\n"; // animation offset (0-1)
code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, anim_offset_rand);\n\n"; // animation offset (0-1)

code += " if (RESTART_ROT_SCALE) {\n";
code += " TRANSFORM[0].xyz = vec3(1.0, 0.0, 0.0);\n";
code += " TRANSFORM[1].xyz = vec3(0.0, 1.0, 0.0);\n";
code += " TRANSFORM[2].xyz = vec3(0.0, 0.0, 1.0);\n";
code += " }\n\n";

code += " if (RESTART_POSITION) {\n";

switch (emission_shape) {
case EMISSION_SHAPE_POINT: {
//do none, identity (will later be multiplied by emission transform)
code += " TRANSFORM = mat4(vec4(1,0,0,0),vec4(0,1,0,0),vec4(0,0,1,0),vec4(0,0,0,1));\n";
code += " TRANSFORM[3].xyz = vec3(0.0, 0.0, 0.0);\n";
} break;
case EMISSION_SHAPE_SPHERE: {
code += " float s = rand_from_seed(alt_seed) * 2.0 - 1.0;\n";
Expand Down

0 comments on commit 082cfd5

Please sign in to comment.