From a879e595814d847c413869fc2c5e8b9628d35ada Mon Sep 17 00:00:00 2001 From: QbieShay Date: Wed, 22 Nov 2023 22:38:14 +0100 Subject: [PATCH] Fixed radial inwards velocity clamping incorrectly (regression from 83488) --- scene/resources/particle_process_material.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp index 2a70deee6cd8..4ed1980826b0 100644 --- a/scene/resources/particle_process_material.cpp +++ b/scene/resources/particle_process_material.cpp @@ -762,8 +762,11 @@ void ParticleProcessMaterial::_update_shader() { code += "}\n"; - code += "vec3 process_radial_displacement(DynamicsParameters param, float lifetime, inout uint alt_seed, mat4 transform, mat4 emission_transform){\n"; + code += "vec3 process_radial_displacement(DynamicsParameters param, float lifetime, inout uint alt_seed, mat4 transform, mat4 emission_transform, float delta){\n"; code += " vec3 radial_displacement = vec3(0.0);\n"; + code += " if (delta < 0.001){\n"; + code += " return radial_displacement;\n"; + code += " }\n"; code += " float radial_displacement_multiplier = 1.0;\n"; if (tex_parameters[PARAM_RADIAL_VELOCITY].is_valid()) { code += " radial_displacement_multiplier = texture(radial_velocity_curve, vec2(lifetime)).r;\n"; @@ -774,7 +777,7 @@ void ParticleProcessMaterial::_update_shader() { code += " }else{radial_displacement = get_random_direction_from_spread(alt_seed, 360.0)* param.radial_velocity;} \n"; code += " if (radial_displacement_multiplier * param.radial_velocity < 0.0){\n // Prevent inwards velocity to flicker once the point is reached."; code += " if (length(radial_displacement) > 0.01){\n"; - code += " radial_displacement = normalize(radial_displacement) * min(abs((radial_displacement_multiplier * param.radial_velocity)), length(transform[3].xyz - global_pivot));\n"; + code += " radial_displacement = normalize(radial_displacement) * min(abs((radial_displacement_multiplier * param.radial_velocity)), length(transform[3].xyz - global_pivot) / delta);\n"; code += " }\n"; code += " \n"; code += " return radial_displacement;\n"; @@ -923,7 +926,7 @@ void ParticleProcessMaterial::_update_shader() { } code += " // calculate all velocity\n"; code += " \n"; - code += " controlled_displacement += process_radial_displacement(dynamic_params, lifetime_percent, alt_seed, TRANSFORM, EMISSION_TRANSFORM);\n"; + code += " controlled_displacement += process_radial_displacement(dynamic_params, lifetime_percent, alt_seed, TRANSFORM, EMISSION_TRANSFORM, DELTA);\n"; code += " \n"; if (tex_parameters[PARAM_DIRECTIONAL_VELOCITY].is_valid()) { code += " controlled_displacement += process_directional_displacement(dynamic_params, lifetime_percent, TRANSFORM, EMISSION_TRANSFORM);\n";