From a9e57343a107f9ec7832ed4e27edb7da7f052a56 Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Mon, 20 Jan 2025 03:16:34 -0500 Subject: [PATCH 1/5] Add tbnMat variable to PBRSurface.glsl Updated to store tbnMat as a publicly accessible variable in the PBRSurface.glsl struct, that way tbnMat won't need recalculated anywhere else in the shader it is needed. --- .../src/main/resources/Common/ShaderLib/module/PBRSurface.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/module/PBRSurface.glsl b/jme3-core/src/main/resources/Common/ShaderLib/module/PBRSurface.glsl index d8105ed543..6394049364 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/module/PBRSurface.glsl +++ b/jme3-core/src/main/resources/Common/ShaderLib/module/PBRSurface.glsl @@ -10,6 +10,7 @@ vec3 normal; // normals w/ normalmap bool frontFacing; //gl_FrontFacing float depth; + mat3 tbnMat; // from texture vec3 albedo; @@ -36,4 +37,4 @@ #endstruct #define PBRSurface StdPBRSurface #endif -#endif \ No newline at end of file +#endif From 337696b7f4055d94665ccdcab0d64cb88f57e816 Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Mon, 20 Jan 2025 03:17:57 -0500 Subject: [PATCH 2/5] Update PBRLightingUtils.glsllib --- .../ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib index e987993fa1..b65bcaaa7f 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib @@ -266,6 +266,7 @@ #if defined(NORMALMAP) || defined(PARALLAXMAP) vec3 tan = normalize(wTangent.xyz); mat3 tbnMat = mat3(tan, wTangent.w * cross( surface.geometryNormal, tan), surface.geometryNormal); + surface.tbnMat = tbnMat; #endif vec2 newTexCoord; @@ -589,4 +590,4 @@ #endif -#endif \ No newline at end of file +#endif From 5dd486954f19f5f2dc0445013337645b7dbd785a Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Mon, 20 Jan 2025 04:39:36 -0500 Subject: [PATCH 3/5] Removed undeclared normal variable that is no longer needed caused a crash trying to assign a non existent variable. but it isn't needed anymore anyways since surface.geometryNormal already is set to = norm by default now --- .../ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib | 2 -- 1 file changed, 2 deletions(-) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib index b65bcaaa7f..8caf02fded 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib @@ -338,8 +338,6 @@ vec3 normal = normalize((normalHeight.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0))); #endif surface.normal = normalize(tbnMat * normal); - #else - surface.normal = normal; #endif //spec gloss tex reads: From 3d6a504ffc3875a4ef46b4c80d7a4f0800369e80 Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Wed, 22 Jan 2025 08:49:28 -0500 Subject: [PATCH 4/5] Update PBRLightingUtils.glsllib --- .../ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib index 8caf02fded..b65bcaaa7f 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib @@ -338,6 +338,8 @@ vec3 normal = normalize((normalHeight.xyz * vec3(2.0, NORMAL_TYPE * 2.0, 2.0) - vec3(1.0, NORMAL_TYPE * 1.0, 1.0))); #endif surface.normal = normalize(tbnMat * normal); + #else + surface.normal = normal; #endif //spec gloss tex reads: From 9f6a16833a34e940f823c941e39bddff3e5c1c0f Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Wed, 22 Jan 2025 08:52:16 -0500 Subject: [PATCH 5/5] Update PBRLightingUtils.glsllib --- .../ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib index b65bcaaa7f..79cb9ea37a 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/module/pbrlighting/PBRLightingUtils.glsllib @@ -339,7 +339,7 @@ #endif surface.normal = normalize(tbnMat * normal); #else - surface.normal = normal; + surface.normal = surface.geometryNormal; #endif //spec gloss tex reads: