godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.71k stars 20.12k forks source link

[TRACKER] DOF Blur quality issues #65116

Open TokisanGames opened 2 years ago

TokisanGames commented 2 years ago

Godot version

9c890ef2f

System information

Windows 11/64, RTX 3070, Vulkan

Issue description

Tracker for depth of field blur issues.

I can pull any of these out into separate issues if desired. Otherwise, the detail is below.

Steps to reproduce

Minimal reproduction project

test_dof_blur.zip

Jitter does nothing

rendering/camera/depth_of_field/depth_of_field_use_jitter doesn't seem to do anything. I see no effect on any bokeh or quality level.

Label3D

Label3D is incorrectly affected by blur

image

Blur Artifacts

Different blur algorithms amounts have different artifacts on movement. This is tested while adjusting focus_distance between near and far and back. This procedure is done all the time when a real camera is autofocusing, or when an First Assistant Camera pulls focus on a camera when filmmaking (a person manually focusing the camera). Every film racks focus. Many video games also use this technique.

Hexagon

Low

Tested w/ f/4, 100 ISO, 250 shutter

This seems to be the reference setting and the best all around, however it has issues.

  • The focal planes (hex/low) move pixels of a focused object up and to the left significantly enough to notice and be disconcerting. It affects details of faces and edges. Racking focus, objects pops up then back down as focus hits and leaves them. It looks like it's using an up/left directional blur instead of a radial blur. You can see on the zoomed image that the top left pixels blur but the bottom right stay static. It only moves pixels when close to the focus plane (eg 2.4-4 for an object @ 3). Outside of that range they don't move.

https://user-images.githubusercontent.com/632766/186451072-b323c0af-e4b7-455b-be89-9fa2e6aaca1e.mp4

moving focus

Very Low

Tested w/ f/4, 100 ISO, 250 shutter

Medium

Tested with f/2, 25 ISO, 250 shutter to get about the same amount of blur.

High

Tested with f/2, 25 ISO, 250 shutter to get about the same amount of blur. Otherwise, no artifacts.

Box

Pretty much the same as Hexagon.

Circle

Tested with f/2, 25 ISO, 250 shutter.

In its current state, this is not usable for a racking focus camera due to artifacts. Performance takes a big hit as well. The blur looks amazing, so it's too bad.

Very low

https://user-images.githubusercontent.com/632766/186460824-8e273f1b-0a9e-41b7-8750-2c299c79d47e.mp4

Low

Medium

High

clayjohn commented 2 years ago

I will update the other points more substantially later, but the Label3D issue comes from it being a transparent object. It doesn't write to depth so it gets treated as if it's at the depth of whatever is behind it. It will have trouble with all screen-space effects utilizing the depth buffer (SSR, SSAO, etc.). The solution is to set the depth draw mode to opaque prepass so it's depth can be written into the depth buffer.

Calinou commented 2 years ago

Regarding jitter, I remember it having a very subtle effect a few months ago. It may have broken with refactoring changes though. Either way, I think that setting should be removed to only perform DoF jitter when TAA is enabled (where jittering effects over time is the most beneficial).

https://github.com/godotengine/godot/pull/57210 has a WIP branch linked in a comment to improve depth of field performance/quality, but its author no longer has time to work on it.

BraqueDown commented 2 years ago

Regarding jitter, I remember it having a very subtle effect a few months ago. It may have broken with refactoring changes though.

It still works, but it's effect is extremely slight, and is masked by using higher quality settings, using a larger blur size, or rendering at a higher resolution.

EDIT: Also, It doesn't look like it has any effect in Circle mode.

ghost commented 2 years ago

I'm working on a fix for an edge artifact that happens at uneven resolutions, which is somewhat related to the https://github.com/godotengine/godot/issues/65116#blur-amount issue described here (I suspect the half_size rendering is the cause for this too). So I'll try to tackle both issues.

I think creating individual issues and checklist linking them in this tracker issue might be easier to follow.