Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two different linearZ inside Falcor #334

Open
zheng95z opened this issue Dec 18, 2022 · 0 comments
Open

Two different linearZ inside Falcor #334

zheng95z opened this issue Dec 18, 2022 · 0 comments

Comments

@zheng95z
Copy link

I found that there are two different implementation of linearZ inside Falcor:

// Linear z and its derivative
if (is_valid(gLinearZAndDeriv))
{
const float linearZ = vsOut.posH.z * vsOut.posH.w;
gLinearZAndDeriv[ipos] = float2(linearZ, max(abs(ddx(linearZ)), abs(ddy(linearZ))));
}

and

if (is_valid(gLinearZ))
{
float4 curPosH = mul(gScene.camera.data.viewProjMatNoJitter, float4(sd.posW, 1.f));
float curLinearZ = curPosH.w;
// TODO: Improve computation of derivatives:
float3 ddxPosW = computeDdxPosW(sd.posW, sd.faceN, invFrameDim);
float3 ddyPosW = computeDdyPosW(sd.posW, sd.faceN, invFrameDim);
float4 curPosH_dx = mul(gScene.camera.data.viewProjMatNoJitter, float4(sd.posW + ddxPosW, 1.f));
float4 curPosH_dy = mul(gScene.camera.data.viewProjMatNoJitter, float4(sd.posW + ddxPosW, 1.f));
float ddxLinearZ = abs(curPosH_dx.w - curLinearZ);
float ddyLinearZ = abs(curPosH_dy.w - curLinearZ);
float dLinearZ = max(ddxLinearZ, ddyLinearZ);
gLinearZ[pixel] = float2(curLinearZ, dLinearZ);
}

Although one of them is generated by rasterization and another is by rt, I believe they both should be posH.w since its view space depth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant