Merge pull request #77631 from KdotJPG/issue-77491-fix-turbulence-noise-scale

Fix `turbulence_noise_scale` for Particle Turbulence
This commit is contained in:
Yuri Sizov 2023-05-31 12:49:49 +02:00 committed by GitHub
commit 943e5b9019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1356,7 +1356,11 @@ float ParticleProcessMaterial::get_turbulence_noise_strength() const {
void ParticleProcessMaterial::set_turbulence_noise_scale(float p_turbulence_noise_scale) {
turbulence_noise_scale = p_turbulence_noise_scale;
float shader_turbulence_noise_scale = (pow(p_turbulence_noise_scale, 0.25) * 5.6234 / 10.0) * 4.0 - 3.0;
const float noise_frequency_when_slider_is_zero = 4.0;
const float max_slider_value = 10.0;
const float curve_exponent = 0.25;
const float curve_rescale = noise_frequency_when_slider_is_zero / pow(max_slider_value, curve_exponent);
float shader_turbulence_noise_scale = pow(p_turbulence_noise_scale, curve_exponent) * curve_rescale - noise_frequency_when_slider_is_zero;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->turbulence_noise_scale, shader_turbulence_noise_scale);
}