Reversed the debug view for displacement to show height instead of depth.

Also add a LerpInverse utility, though I ended up not using it with these changes, it should be handle elsewhere.
This commit is contained in:
Chris Santora
2021-05-20 17:02:26 -07:00
parent ccfb8a7516
commit f6b9f0e0fb
2 changed files with 18 additions and 2 deletions
@@ -342,8 +342,11 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
if(o_debugDrawMode == DebugDrawMode::Displacement)
{
float depth = GetNormalizedDepth(-MaterialSrg::m_displacementMax, -MaterialSrg::m_displacementMin, IN.m_uv[MaterialSrg::m_parallaxUvIndex], float2(0,0), float2(0,0));
return DebugOutput(float3(depth,depth,depth));
float startDepth = -MaterialSrg::m_displacementMax;
float stopDepth = -MaterialSrg::m_displacementMin;
float depth = GetNormalizedDepth(startDepth, stopDepth, IN.m_uv[MaterialSrg::m_parallaxUvIndex], float2(0,0), float2(0,0));
float height = 1 - saturate(depth);
return DebugOutput(float3(height,height,height));
}
if(o_debugDrawMode == DebugDrawMode::FinalBlendWeights)
@@ -225,3 +225,16 @@ float NextRandomFloatUniform(inout uint seed)
seed = Xorshift(seed);
return (float)seed / 4294967295.0f;
}
//! Returns the inverse of lerp, 't', such that value = lerp(a, b, t), or returns 0 when a == b.
float LerpInverse(float a, float b, float value)
{
if(abs(a - b) <= EPSILON)
{
return 0.0;
}
else
{
return (value - a) / (b - a);
}
}