Skip to content

Commit

Permalink
Merge pull request #75999 from clayjohn/Particles-angle-rand
Browse files Browse the repository at this point in the history
Use angle_rand to calculate base_angle in particles process material
  • Loading branch information
YuriSizov authored Apr 14, 2023
2 parents f5f796b + 821917b commit bd3286e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scene/2d/cpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,12 @@ void CPUParticles2D::_particles_process(double p_delta) {
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->sample(0);
}*/

real_t tex_angle = 0.0;
real_t tex_angle = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_angle = curve_parameters[PARAM_ANGLE]->sample(tv);
}

real_t tex_anim_offset = 0.0;
real_t tex_anim_offset = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_anim_offset = curve_parameters[PARAM_ANGLE]->sample(tv);
}
Expand Down
4 changes: 2 additions & 2 deletions scene/3d/cpu_particles_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,12 @@ void CPUParticles3D::_particles_process(double p_delta) {
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->sample(0);
}*/

real_t tex_angle = 0.0;
real_t tex_angle = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_angle = curve_parameters[PARAM_ANGLE]->sample(tv);
}

real_t tex_anim_offset = 0.0;
real_t tex_anim_offset = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_anim_offset = curve_parameters[PARAM_ANGLE]->sample(tv);
}
Expand Down
4 changes: 2 additions & 2 deletions scene/resources/particle_process_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void ParticleProcessMaterial::_update_shader() {
if (tex_parameters[PARAM_ANGLE].is_valid()) {
code += " float tex_angle = textureLod(angle_texture, vec2(0.0, 0.0), 0.0).r;\n";
} else {
code += " float tex_angle = 0.0;\n";
code += " float tex_angle = 1.0;\n";
}

if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) {
Expand Down Expand Up @@ -737,7 +737,7 @@ void ParticleProcessMaterial::_update_shader() {
code += " VELOCITY = normalize(VELOCITY) * v;\n";
code += " }\n";
code += " }\n";
code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, rand_from_seed(alt_seed));\n";
code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, angle_rand);\n";
code += " base_angle += CUSTOM.y * LIFETIME * (tex_angular_velocity) * mix(angular_velocity_min,angular_velocity_max, rand_from_seed(alt_seed));\n";
code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle
code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));\n"; // angle
Expand Down

0 comments on commit bd3286e

Please sign in to comment.