Skip to content

Commit

Permalink
PBR Shader: support two-channel normal maps
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 10, 2024
1 parent 3e4dd9b commit 79fa833
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Shaders/PBR/private/PBR_Textures.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,11 @@ float3 GetMicroNormal(PBRMaterialShaderInfo Material,

MicroNormal = MicroNormal * float3(2.0, 2.0, 2.0) - float3(1.0, 1.0, 1.0);
MicroNormal.xy *= Material.Basic.NormalScale;
if (MicroNormal.z < 0.0)
{
// The texture does not contain the Z component of the normal.
MicroNormal.z = sqrt(max(1.0 - dot(MicroNormal.xy, MicroNormal.xy), 0.0));
}
return MicroNormal;
}

Expand Down Expand Up @@ -710,6 +715,11 @@ float3 GetClearcoatNormal(PBRMaterialShaderInfo Material,

ClearcoatNormal = ClearcoatNormal * float3(2.0, 2.0, 2.0) - float3(1.0, 1.0, 1.0);
ClearcoatNormal.xy *= Material.Basic.ClearcoatNormalScale;
if (ClearcoatNormal.z < 0.0)
{
// The texture does not contain the Z component of the normal.
ClearcoatNormal.z = sqrt(max(1.0 - dot(ClearcoatNormal.xy, ClearcoatNormal.xy), 0.0));
}
return ClearcoatNormal;
}

Expand Down

0 comments on commit 79fa833

Please sign in to comment.