GPUOpen-LibrariesAndSDKs / FidelityFX-SDK

The main repository for the FidelityFX SDK.
Other
835 stars 80 forks source link

Added support for lens distortion offsets in Frame Interpolation #86

Open hsiversson opened 1 month ago

hsiversson commented 1 month ago

This change contains the changes needed to support an optional buffer that can describe application defined distortion offsets used to apply distortion as a post processing effect.

FrameGenerationDispatch can to accept an optional distortion field resource. The distortion field resource is expected to have a 4-channel floating point format. The following data layout is expected:

XY: The offset which can be applied to go from source UV to distorted UV. ZW: The offset which can be applied to go from distorted UV to source UV.

Worth knowing is that this implementation is somewhat barebone, and could potentially use some additional work to become fully generic and cross-platform. For example, in the current setup, I did not find a good solution on how to let the app provide the optional buffer when using the frame generation dispatch callback,

How to test:

  1. Build new FfxApi DLLs using the changes.
  2. Replace DLLs in the PrebuiltSignedDLL folder with the newly built DLLs.
  3. Build the FSR sample.
  4. Launch the sample.
  5. Disable "Use Callback" mode for frame interpolation.
  6. Under "Tonemapping" there are three new controls for Lens Distortion. Use the "Enable" flag to toggle distortion on/off.
  7. Under "Upscaling" there's a new flag called "Use Distortion Field" which lets you toggle the usage of the distortion field resource.
  8. Set "Use Distortion Field" to off and "Lens Distortion Enable" to true to see how FI would currently be affected by distortion effects. Then enable "Use Distortion Field" again to see how the extra resource fixes the artifacts.

PLEASE NOTE! There's also a small bugfix in ffx_frameinterpolation_game_motion_vector_field.h: Incorrect sample of previous backbuffer was taken instead of current backbuffer.