PR feedback
This commit is contained in:
@@ -150,7 +150,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
|
||||
GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], MaterialSrg::m_depthFactor, MaterialSrg::m_depthOffset,
|
||||
ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth, displacementIsClipped);
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth, displacementIsClipped, IN.m_position.w);
|
||||
|
||||
// Apply second part of the offset to the detail UV (see comment above)
|
||||
IN.m_detailUv[MaterialSrg::m_parallaxUvIndex] -= IN.m_uv[MaterialSrg::m_parallaxUvIndex];
|
||||
@@ -163,7 +163,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
{
|
||||
DirectionalLightShadow::GetShadowCoords(shadowIndex, IN.m_worldPosition, IN.m_shadowCoords);
|
||||
}
|
||||
IN.m_position.w = mul(ViewSrg::m_viewProjectionMatrix, IN.m_worldPosition).z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ option bool prefix##o_useDepthMap;
|
||||
|
||||
void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float depthFactor, float depthOffset,
|
||||
float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
|
||||
inout float2 uv, inout float3 worldPosition, inout float depth, out bool isClipped)
|
||||
inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS, out bool isClipped)
|
||||
{
|
||||
if(o_parallax_feature_enabled)
|
||||
{
|
||||
@@ -72,7 +72,8 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float dep
|
||||
objectWorldMatrix,
|
||||
ViewSrg::m_viewProjectionMatrix);
|
||||
|
||||
depth = pdo.m_depth;
|
||||
depthCS = pdo.m_depthCS;
|
||||
depthNDC = pdo.m_depthNDC;
|
||||
|
||||
worldPosition = pdo.m_worldPosition;
|
||||
}
|
||||
@@ -82,9 +83,17 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float dep
|
||||
|
||||
void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float depthFactor, float depthOffset,
|
||||
float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
|
||||
inout float2 uv, inout float3 worldPosition, inout float depth)
|
||||
inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS)
|
||||
{
|
||||
bool isClipped;
|
||||
GetParallaxInput(normal, tangent, bitangent, depthFactor, depthOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depth, isClipped);
|
||||
GetParallaxInput(normal, tangent, bitangent, depthFactor, depthOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS, isClipped);
|
||||
}
|
||||
|
||||
void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float depthFactor, float depthOffset,
|
||||
float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
|
||||
inout float2 uv, inout float3 worldPosition, inout float depthNDC)
|
||||
{
|
||||
float depthCS;
|
||||
GetParallaxInput(normal, tangent, bitangent, depthFactor, depthOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS);
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -130,9 +130,9 @@ VSOutput ForwardPassVS(VSInput IN)
|
||||
|
||||
// ---------- Pixel Shader ----------
|
||||
|
||||
PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depth)
|
||||
PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depthNDC)
|
||||
{
|
||||
depth = IN.m_position.z;
|
||||
depthNDC = IN.m_position.z;
|
||||
|
||||
// ------- Tangents & Bitangets -------
|
||||
|
||||
@@ -185,7 +185,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
float parallaxOverallFactor = MaterialSrg::m_displacementMax - MaterialSrg::m_displacementMin;
|
||||
GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], parallaxOverallFactor, parallaxOverallOffset,
|
||||
ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth, displacementIsClipped);
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depthNDC, IN.m_position.w, displacementIsClipped);
|
||||
|
||||
// Adjust directional light shadow coorinates for parallax correction
|
||||
if(o_parallax_enablePixelDepthOffset)
|
||||
@@ -195,7 +195,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
{
|
||||
DirectionalLightShadow::GetShadowCoords(shadowIndex, IN.m_worldPosition, IN.m_shadowCoords);
|
||||
}
|
||||
IN.m_position.w = mul(ViewSrg::m_viewProjectionMatrix, IN.m_worldPosition).z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -109,7 +109,7 @@ PSDepthOutput MainPS(VertexOutput IN, bool isFrontFace : SV_IsFrontFace)
|
||||
|
||||
GetDepth_Setup(IN.m_blendMask);
|
||||
|
||||
float depth;
|
||||
float depthNDC;
|
||||
|
||||
float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
|
||||
float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3();
|
||||
@@ -118,9 +118,9 @@ PSDepthOutput MainPS(VertexOutput IN, bool isFrontFace : SV_IsFrontFace)
|
||||
float parallaxOverallFactor = MaterialSrg::m_displacementMax - MaterialSrg::m_displacementMin;
|
||||
GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], parallaxOverallFactor, parallaxOverallOffset,
|
||||
ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth);
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depthNDC);
|
||||
|
||||
OUT.m_depth = depth;
|
||||
OUT.m_depth = depthNDC;
|
||||
}
|
||||
|
||||
return OUT;
|
||||
|
||||
@@ -105,7 +105,7 @@ VSOutput StandardPbr_ForwardPassVS(VSInput IN)
|
||||
|
||||
// ---------- Pixel Shader ----------
|
||||
|
||||
PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depth)
|
||||
PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depthNDC)
|
||||
{
|
||||
// ------- Tangents & Bitangets -------
|
||||
|
||||
@@ -125,7 +125,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
|
||||
// ------- Depth & Parallax -------
|
||||
|
||||
depth = IN.m_position.z;
|
||||
depthNDC = IN.m_position.z;
|
||||
|
||||
bool displacementIsClipped = false;
|
||||
|
||||
@@ -137,7 +137,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3();
|
||||
GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], MaterialSrg::m_depthFactor, MaterialSrg::m_depthOffset,
|
||||
ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth, displacementIsClipped);
|
||||
IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depthNDC, IN.m_position.w, displacementIsClipped);
|
||||
|
||||
// Adjust directional light shadow coorinates for parallax correction
|
||||
if(o_parallax_enablePixelDepthOffset)
|
||||
@@ -147,7 +147,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
{
|
||||
DirectionalLightShadow::GetShadowCoords(shadowIndex, IN.m_worldPosition, IN.m_shadowCoords);
|
||||
}
|
||||
IN.m_position.w = mul(ViewSrg::m_viewProjectionMatrix, IN.m_worldPosition).z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -398,7 +398,8 @@ ParallaxOffset GetParallaxOffset( float depthFactor,
|
||||
|
||||
struct PixelDepthOffset
|
||||
{
|
||||
float m_depth;
|
||||
float m_depthNDC; //!< The new depth value, in normalized device coordinates (used for final depth output)
|
||||
float m_depthCS; //!< The new depth value, in clip space (can be used for other operations like light culling)
|
||||
float3 m_worldPosition;
|
||||
};
|
||||
|
||||
@@ -432,7 +433,8 @@ PixelDepthOffset CalcPixelDepthOffset( float depthFactor,
|
||||
float4 clipOffsetPosition = mul(viewProjectionMatrix, float4(worldOffsetPosition, 1.0));
|
||||
|
||||
PixelDepthOffset pdo;
|
||||
pdo.m_depth = clipOffsetPosition.z / clipOffsetPosition.w;
|
||||
pdo.m_depthCS = clipOffsetPosition.z;
|
||||
pdo.m_depthNDC = clipOffsetPosition.z / clipOffsetPosition.w;
|
||||
pdo.m_worldPosition = worldOffsetPosition;
|
||||
return pdo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user