-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix DoF's dependency on resolution #57210
Conversation
This looks fine to me, but I am worried about the performance impact, especially when using the circular bokeh mode. Can you test circular bokeh on both low res, HD, and 4K? Or maybe @Calinou is able to test on HD and 4K? |
@@ -2362,6 +2362,8 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende | |||
|
|||
// @TODO IMPLEMENT MULTIVIEW, all effects need to support stereo buffers or effects are only applied to the left eye | |||
|
|||
float resolution_factor = p_render_data->cam_vaspect ? (float(rb->internal_width) / 1920.0) : (float(rb->internal_height) / 1080.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does 1920x1080 correspond to something specific in the renderer? It seems a bit weird to see this hardcoded, wouldn't it need to reflect the actual game viewport size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see this was discussed in #56911 (comment). A comment to justify the hardcoded reference size would be useful.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
@clayjohn I tested with Circular and High Quality Bokeh. With this patch:
Without this patch:
Picking a higher reference resolution would most likely improve the situation for 4k as well, but I'm not sure that's the solution or if one is required. Any suggestions? |
Picking a higher reference resolution is the same as decreasing the fixed I see two solutions and I am torn between the two:
Number 1 is nice, because we want the default to be "just works". That being said the performance cost is pretty hard to swallow. The end result would be "it just works*" (* but runs too slow to use). Number 2 is better for performance and for users who don't care about blur amount as much. Can you do another table like the above, but for Box blur and hexagon blur? They both should scale much better with resolution. If the difference isn't as bad with them, then I lean towards 1. |
I feel we should change the circle bokeh shape to not have performance that depends on DoF amount, even if this means it'll look worse at higher resolutions. This amount-dependent caveat is just too bothersome for game developers to handle, especially if they want to expose circle bokeh as an opt-in setting for those with fast GPUs (and keep box/hexagon shape by default). It can also cause unexpected performance dips when animating the DoF amount at run-time. I remember discussing this with @lyuma in I would really prefer not to have resolution-dependent DoF as the default, as many developers don't test their games on high-resolution displays (since they don't own the required hardware in the first place). Also, resolution-dependent DoF can give some players an advantage if the blur effect is intended to obstruct something the player shouldn't see. If anyone wants to work on this, I made a testing project: test_depth_of_field_circle.zip |
I wrote a little Python function, in order to understand how many iterations are being made for the circular bokeh inside this for loop: def iterations(blur_scale, blur_size):
radius = blur_scale
i = 0
while radius < blur_size:
radius += blur_scale / radius
# print(radius)
i += 1
return i
And here's some results:
The increase in iterations looks pretty steep when cycling between DoF amount and qualities. |
Your resolution multiplier would make this dependent on resolution. You can see the default setting is to blur over 64 pixels * dof_amount. If we wanted to keep the cost the same as screen size changed we could scale both the |
Yes, I was thinking about
I'll try to find a sweet spot where quality doesn't visibly chang, but performance improves. |
The new circle mode looks great! Nice work 🙂
I think your new mode can replace the existing Circle mode, as offline rendering with Godot is considered to be a corner case. It probably doesn't warrant having entire rendering modes on its own. Pushing up all other settings (such as shadow quality and DoF quality will usually make rendering look good enough (and be slow enough) already. |
@ceLoFaN Could you open a pull request with the optimized circle DoF (assuming it's this branch)? Thanks in advance 🙂 |
Sorry for the long silence, but I've been dealing with various health issues for the past 5 weeks or so. Here's the branch if anybody wants to tidy it up or give it a spin: https://github.com/godotengine/godot/compare/master...ceLoFaN:improve-dof?expand=1 Some numbers might need more tweaking to get the before advertised FPS, but the good news is I fixed 2 bugs that resulted in visual artifacts at various DOF settings (one was an implementation mistake, and one was a scaling mistake that happened on odd numbered resolution, as in 1919x1079), and it resembles the original DOF better. I was also messing with a denoising step at the time, which you guys might not like as much, but to me looked somewhat promising. Also, Also, the other DOF variants (box, hex...) might need to be adjusted because of the scaling bug-fix... not sure haven't tested. Unfortunately, I don't think I'll be able to resume work on this for the forseable future, but I pushed what I had at the time on my working branch. |
Bumping the milestone to 4.x. @ceLoFaN's work on an optimized circle mode is very interesting and we should properly evaluate whether it can replace the current circle mode or be added as another option. At this point, I don't think we should decouple resolution from DoF until we have a good handle on the resulting performance issues. So this is 4.x work. |
fixes #56911
This has no impact on how the glow effect scales with the resolution, but I couldn't be bothered to do a different recording.
demo-.6.mp4