diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-10-08 00:51:48 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-10-08 00:55:43 -0300 |
commit | 14494dddd04bb9b6964940cdde97fe0364299b96 (patch) | |
tree | fb91b72e0f8d160a336d02e6e8e2cbfbd5bb0693 /scene/resources/particles_material.cpp | |
parent | b17e71b6e5e035f49b5b3b5b55b9cdac80215d72 (diff) |
Fixes to CPU particles for performance and avoiding NaNs.
Diffstat (limited to 'scene/resources/particles_material.cpp')
-rw-r--r-- | scene/resources/particles_material.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 6f67ba8af1..ba48982fda 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -308,7 +308,7 @@ void ParticlesMaterial::_update_shader() { code += " float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);\n"; code += " vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));\n"; code += " vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));\n"; - code += " direction_yz.z = direction_yz.z / sqrt(direction_yz.z); // better uniform distribution\n"; + code += " direction_yz.z = direction_yz.z / max(0.0001,sqrt(abs(direction_yz.z))); // better uniform distribution\n"; code += " vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);\n"; code += " direction = normalize(direction);\n"; code += " VELOCITY = direction * initial_linear_velocity * mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n"; |