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

Handle dilated depth more gracefully for non-inverted depth. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/ffx-fsr2-api/shaders/ffx_fsr2_callbacks_glsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ void SetReconstructedDepth(FFX_MIN16_I2 iPxSample, FfxUInt32 uValue)
void StoreDilatedDepth(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth)
{
#if defined(FSR2_BIND_UAV_DILATED_DEPTH)
#if !FFX_FSR2_OPTION_INVERTED_DEPTH
fDepth = 1.0 - fDepth; // Preserve precision as well as we can in FP16.
#endif
//FfxUInt32 uDepth = f32tof16(fDepth);
imageStore(rw_dilatedDepth, iPxPos, vec4(fDepth, 0.0f, 0.0f, 0.0f));
#endif
Expand Down Expand Up @@ -658,7 +661,11 @@ FfxFloat32x2 SampleDilatedMotionVector(FfxFloat32x2 fUV)
FfxFloat32 LoadDilatedDepth(FFX_MIN16_I2 iPxInput)
{
#if defined(FSR2_BIND_SRV_DILATED_DEPTH)
return texelFetch(r_dilatedDepth, iPxInput, 0).r;
FfxFloat32 fDepth = texelFetch(r_dilatedDepth, iPxInput, 0).r;
#if !FFX_FSR2_OPTION_INVERTED_DEPTH
fDepth = 1.0 - fDepth; // Reconstruct from FP16.
#endif
return fDepth;
#else
return 0.f;
#endif
Expand Down
9 changes: 8 additions & 1 deletion src/ffx-fsr2-api/shaders/ffx_fsr2_callbacks_hlsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,9 @@ void SetReconstructedDepth(FFX_MIN16_I2 iPxSample, const FfxUInt32 uValue)
void StoreDilatedDepth(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth)
{
#if defined(FSR2_BIND_UAV_DILATED_DEPTH) || defined(FFX_INTERNAL)
#if !FFX_FSR2_OPTION_INVERTED_DEPTH
fDepth = 1.0 - fDepth; // Preserve precision as well as we can in FP16.
#endif
//FfxUInt32 uDepth = f32tof16(fDepth);
rw_dilatedDepth[iPxPos] = fDepth;
#endif
Expand Down Expand Up @@ -828,7 +831,11 @@ FfxFloat32x2 SampleDilatedMotionVector(FfxFloat32x2 fUV)
FfxFloat32 LoadDilatedDepth(FFX_MIN16_I2 iPxInput)
{
#if defined(FSR2_BIND_SRV_DILATED_DEPTH) || defined(FFX_INTERNAL)
return r_dilatedDepth[iPxInput];
FfxFloat32 fDepth = r_dilatedDepth[iPxInput];
#if !FFX_FSR2_OPTION_INVERTED_DEPTH
fDepth = 1.0 - fDepth; // Reconstruct from FP16.
#endif
return fDepth;
#else
return 0.f;
#endif
Expand Down