diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl | 4 | ||||
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_normal_map.glsl | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl index 6091a5c834a..c0821085c8d 100644 --- a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl @@ -187,8 +187,10 @@ struct ClosureTransparency { struct GlobalData { /** World position. */ vec3 P; - /** Surface Normal. */ + /** Surface Normal. Normalized, overriden by bump displacement. */ vec3 N; + /** Raw interpolated normal (non-normalized) data. */ + vec3 Ni; /** Geometric Normal. */ vec3 Ng; /** Curve Tangent Space. */ diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_normal_map.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_normal_map.glsl index a54dc59ddfe..3fc4992f7c4 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_normal_map.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_normal_map.glsl @@ -3,13 +3,13 @@ void node_normal_map(vec4 tangent, vec3 texnormal, out vec3 outnormal) { if (all(equal(tangent, vec4(0.0, 0.0, 0.0, 1.0)))) { - outnormal = g_data.N; + outnormal = g_data.Ni; return; } tangent *= (FrontFacing ? 1.0 : -1.0); - vec3 B = tangent.w * cross(g_data.N, tangent.xyz) * sign(ObjectInfo.w); + vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w); - outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.N; + outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.Ni; outnormal = normalize(outnormal); } #endif |