Add **Depth Offset to materials**

This commit is contained in:
Wojtek Figat
2023-01-29 22:09:51 +01:00
parent a214c14a4d
commit a219a3d2eb
13 changed files with 73 additions and 13 deletions

View File

@@ -22,6 +22,9 @@ void PS_GBuffer(
#if USE_GBUFFER_CUSTOM_DATA
,out float4 RT3 : SV_Target4
#endif
#endif
#if USE_DEPTH_OFFSET
,out float Depth : SV_Depth
#endif
)
{
@@ -36,11 +39,16 @@ void PS_GBuffer(
MaterialInput materialInput = GetMaterialInput(input);
Material material = GetMaterialPS(materialInput);
// Depth offset
#if USE_DEPTH_OFFSET
Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset);
#endif
// Masking
#if MATERIAL_MASKED
clip(material.Mask - MATERIAL_MASK_THRESHOLD);
#endif
#if USE_LIGHTMAP
float3 diffuseColor = GetDiffuseColor(material.Color, material.Metalness);
float3 specularColor = GetSpecularColor(material.Color, material.Specular, material.Metalness);