From 851880ed34c8214d6c65068a345e478193f6ee4b Mon Sep 17 00:00:00 2001 From: Ignacio Castano Date: Tue, 26 May 2026 10:00:07 -0700 Subject: [PATCH] Unpack normal maps using Z reconstruction. --- .../Shader/Built-In/glTFIncludes/glTFUnityStandardInput.cginc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardInput.cginc b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardInput.cginc index 52ca06d3c..3fb152591 100644 --- a/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardInput.cginc +++ b/Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardInput.cginc @@ -238,6 +238,9 @@ half3 NormalInTangentSpace(float2 texcoords) // This is a replacement for UnityStandardUtils UnpackScaleNormalRGorAG to use XYZ normals even with DXT5nm enabled half4 packedNormal = tex2D(normalTexture, texcoords); half3 normal = packedNormal.xyz * 2 - 1; + // Reconstruct Z from X,Y. + // This makes two-channel normalmaps (BC5 / EAC_RG) work and matches the behavior of Unity's own shaders. + normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy))); #if (SHADER_TARGET >= 30) // SM2.0: instruction count limitation // SM2.0: normal scaler is not supported