From a789c2420924a7e3d33619e712c39e635640a1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Wed, 25 Aug 2021 16:49:08 +0200 Subject: [PATCH] HDR: Fix model-combined when not using a normal map --- Shaders/HDR/geometry-combined.vert | 18 ++++++++++++++---- defaults.xml | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Shaders/HDR/geometry-combined.vert b/Shaders/HDR/geometry-combined.vert index f1ad780f5..2b9d8f144 100644 --- a/Shaders/HDR/geometry-combined.vert +++ b/Shaders/HDR/geometry-combined.vert @@ -9,6 +9,8 @@ layout(location = 7) in vec3 binormal; out vec2 texCoord; out mat3 TBN; +uniform int normalmap_enabled; + uniform mat4 osg_ModelViewProjectionMatrix; uniform mat3 osg_NormalMatrix; @@ -17,8 +19,16 @@ void main() gl_Position = osg_ModelViewProjectionMatrix * pos; texCoord = multiTexCoord0.st; - vec3 T = normalize(osg_NormalMatrix * tangent); - vec3 B = normalize(osg_NormalMatrix * binormal); - vec3 N = normalize(osg_NormalMatrix * normal); - TBN = mat3(T, B, N); + vec3 N = normalize(normal); + vec3 T, B; + if (normalmap_enabled > 0) { + T = tangent; + B = binormal; + } else { + T = cross(N, vec3(1.0, 0.0, 0.0)); + B = cross(N, T); + } + TBN = mat3(normalize(osg_NormalMatrix * T), + normalize(osg_NormalMatrix * B), + normalize(osg_NormalMatrix * N)); } diff --git a/defaults.xml b/defaults.xml index e9bfbc92d..abb9c8c86 100644 --- a/defaults.xml +++ b/defaults.xml @@ -386,8 +386,8 @@ Started September 2000 by David Megginson, david@megginson.com 2 0.0 - 1.0 - 6.0 + 0.5 + 8.0 false false