1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

fix: avoid shader crash on null vector and negative x vector

This commit is contained in:
Kasper Frandsen
2024-04-17 17:33:30 +01:00
parent 30e71782af
commit f8d08a8376
2 changed files with 4 additions and 4 deletions

View File

@@ -635,9 +635,9 @@ void ParticleProcessMaterial::_update_shader() {
code += " \n";
code += " float ring_spawn_angle = rand_from_seed(alt_seed) * 2.0 * pi;\n";
code += " float ring_random_radius = rand_from_seed(alt_seed) * (emission_ring_radius - emission_ring_inner_radius) + emission_ring_inner_radius;\n";
code += " vec3 axis = normalize(emission_ring_axis);\n";
code += " vec3 axis = emission_ring_axis == vec3(0.0) ? vec3(0.0, 0.0, 1.0) : normalize(emission_ring_axis);\n";
code += " vec3 ortho_axis = vec3(0.0);\n";
code += " if (axis == vec3(1.0, 0.0, 0.0)) {\n";
code += " if (abs(axis) == vec3(1.0, 0.0, 0.0)) {\n";
code += " ortho_axis = cross(axis, vec3(0.0, 1.0, 0.0));\n";
code += " } else {\n";
code += " ortho_axis = cross(axis, vec3(1.0, 0.0, 0.0));\n";