NVIDIAGameWorks / RayTracingDenoiser

NVIDIA Ray Tracing Denoiser
Other
504 stars 46 forks source link

[REBLUR] Potential bug with transforming Xprev to view space #66

Closed nuno-cardoso closed 1 year ago

nuno-cardoso commented 1 year ago

Hello, I am integrating Reblur denoiser, using only the shaders, so not using the C++ code side. While debugging the denoiser code i found the following.

In the shader REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli, line 250, i see Xprev is transformed to view space using affine transform, so it includes translation: float3 Xvprev = STL::Geometry::AffineTransform( gWorldToViewPrev, Xprev );

But before, the variable Xprev gets its value from variable X which is transformed by rotating only Xv, so no translation included in the transformation. // Current position float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float3 X = STL::Geometry::RotateVector( gViewToWorld, Xv ); ... float3 Xprev = X; ...

It seems the algorithm is doing transformations between world and view spaces assuming only rotations. If am not missing anything, shouldn't the AffineTransform of Xprev in line 250 be a rotation (code below)? float3 Xvprev = STL::Geometry::RotateVector( gWorldToViewPrev, Xprev );

nuno-cardoso commented 1 year ago

Hi, I missed the detail matrices in reblur are camera relative. Apologies for the wrong post.

dzhdanNV commented 1 year ago

Right. "Prev" transform includes movement "delta", this is why "affine" transform is needed. In the current frame internal matrices always have 0 translation.