0
$\begingroup$

I'm trying to perform forward pixel projection based on previous frame depth. Using UV, I'm reading prevDepth for given pixel and based on that I'm recreating worldPos in camera space (where (0, 0, 0) is camera position). Then I offset this position using previous frame camera position to find prevWorldPos in camera space.

Then I'm doing standard matrix multiplication to get ndc and then prev frame uv. So, it works quite nice without any additional history buffer or using pixel neighbours, at least for camera rotation.

When it comes to camera translation, value of prevUV is the same as uv and it results in no changes in affected pixels and it destroys the reprojection. And I don't understand why.

float3 worldPosition = GetWorldPosFromUV(uv, prevDepth); // Current frame worldPos in camera space
float3 prevWorldPosition = worldPosition + (currFrameCameraOffset - prevFrameCameraOffset); // Transform to camera space position in previous frame

float4 ndcPrev = mul(float4(prevWorldPosition, 1.0f), viewProjMatrixPrevFrame); 
ndcPrev.xyz /= ndcPrev.w;
float2 prevUV = ndcPrev.xy * float2(0.5f, -0.5f) + float2(0.5f, 0.5f);

return prevUV;

enter image description here

$\endgroup$
2
  • $\begingroup$ Why do you use the previous frame depth buffer with the current frame UV? That doesn't seem to make sense. Wouldn't you use the current frame depth buffer to get the current frame world position? $\endgroup$ Sep 20 at 19:57
  • $\begingroup$ @NathanReed Sorry, I didn't make it clear. I'm using kind of "special" buffer which is tracking depth of special objects not available in normal depth buffer. I'm working on optimization to calculate pixels only when something changes, because that objects are really expensive to render. So if I skip calculation for that pixels, I lack "special" depth buffer for current frame and I have to use previous frame depth. $\endgroup$ Sep 20 at 20:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.