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

Depth of Field implementation using render passes #7210

Merged
merged 2 commits into from
Dec 20, 2024
Merged

Depth of Field implementation using render passes #7210

merged 2 commits into from
Dec 20, 2024

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Dec 18, 2024

Implementation of DOF effect using render passes, and its integration to CameraFrame.

Algorithm:

  • CoC texture is rendered, containing near and far values for circle of confusion (blur amount)
  • far blur texture is rendered by downscaling the scene color texture premultiplied by the CoC far, to avoid sharp objects being blurred into the background
  • blur texture generated, containing either near or far blur, based on the CoC
  • this is then used (or upscaled when low res) during the composition
  • there are two quality levels, related to the texture resolutions used by these render passes

Public API (see code for JSDocs)

CameraFrame.dof = {
        enabled: false,
        focusDistance: 100,
        focusRange: 10,
        blurRadius: 3,
        blurRings: 4,
        blurRingPoints: 5,
        highQuality: true
    };
// new module to expose generic kernel generation functionality
static Kernel.concentric(numRings, numPoints)

Other changes (related to recent change to expose screen depth in linear space)

  • fixes to linear depth generation (clear color was not handled correctly), which fixes few small issues with passes depending on this (TAA, SSAO)
  • TAA reprojection fix due to not using linear depth correctly.

Performance

Screenshot 2024-12-18 at 15 09 38

References

DOF Example

DOF disabled:
disabled

DOF enabled:
enabled

DOF more extreme settings
strong

Debug CoC rendering
coc

@mvaligursky mvaligursky self-assigned this Dec 18, 2024
@mvaligursky mvaligursky added feature area: graphics Graphics related issue labels Dec 18, 2024
@mvaligursky mvaligursky requested a review from a team December 18, 2024 15:10
@mvaligursky mvaligursky mentioned this pull request Dec 18, 2024
9 tasks
@mvaligursky mvaligursky merged commit 54aa610 into main Dec 20, 2024
8 checks passed
@mvaligursky mvaligursky deleted the mv-dof branch December 20, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants