[Bf-blender-cvs] [aa2e978bd8b] master: Fix T79557 EEVEE: Normalize in vector math node is not null vector safe
Clément Foucault
noreply at git.blender.org
Fri Sep 18 23:42:53 CEST 2020
Commit: aa2e978bd8b47dbc06826698b07d850cdd499568
Author: Clément Foucault
Date: Fri Sep 18 23:42:43 2020 +0200
Branches: master
https://developer.blender.org/rBaa2e978bd8b47dbc06826698b07d850cdd499568
Fix T79557 EEVEE: Normalize in vector math node is not null vector safe
This add basic null safe handling for this operation.
===================================================================
M source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
===================================================================
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
index 256fdcafe3c..0b65fdb229a 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
@@ -64,7 +64,12 @@ void vector_math_scale(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector,
void vector_math_normalize(
vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
- outVector = normalize(a);
+ outVector = a;
+ /* Safe version of normalize(a). */
+ float lenSquared = dot(a, a);
+ if (lenSquared > 0.0) {
+ outVector *= inversesqrt(lenSquared);
+ }
}
void vector_math_snap(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
More information about the Bf-blender-cvs
mailing list