Depth of Field Help

  • Zireael
  • Topic Author
More
6 years 7 months ago - 6 years 7 months ago #1 by Zireael Depth of Field Help was created by Zireael


Is it possible to make the depth of field bleed outwards from an object's edges?

I've noticed that instead blurred objects become "thinner", it looks like the edges shift inwards, which looks bad and does not resemble real DOF



Can anything be done about this?
Last edit: 6 years 7 months ago by Zireael.

Please Log in or Create an account to join the conversation.

  • FierySwordswoman
More
6 years 7 months ago #2 by FierySwordswoman Replied by FierySwordswoman on topic Depth of Field Help
Adjust the settings some and try different DOF styles.
I prefer Matso, personally. Not as much customization as Advanced, but produces a better overall result.

Please Log in or Create an account to join the conversation.

  • Zireael
  • Topic Author
More
6 years 7 months ago #3 by Zireael Replied by Zireael on topic Depth of Field Help

FierySwordswoman wrote: Adjust the settings some and try different DOF styles.
I prefer Matso, personally. Not as much customization as Advanced, but produces a better overall result.


I only use DOF for screenshots, everything except Marty's is rubbish if you want real high quality results.

How is telling me to adjust settings helpful in any way? I already do that extensively, I wanted help from someone who knew more than me.

Please Log in or Create an account to join the conversation.

  • FierySwordswoman
More
6 years 7 months ago #4 by FierySwordswoman Replied by FierySwordswoman on topic Depth of Field Help
Alright, I got some pretty pictures.
Now, I'm not a shader programmer, I mostly just work in GIMP and a tiny bit in Blender, so my explanations might sound weird...

When blurring something, you need information from everything around it. When it can't get information (hitting edge of blur region), it refers to an abyss policy, usually a clamp (take what information it *does* have and stretch it to fill the gaps) or void (just blend with alpha/transparency).
In the DOF shaders, they have to decide between two abyss policies: blur everything or limit based on local depth.
This results in two artifacts depending on which one of the two the shader favors...
EDIT: Didn't like the amount of images I had. Here's links.

Depth-based approaches give sharp edges, as demonstrated here:
i.imgur.com/hCqRllV.png
Here's RingDOF since it leans heavily in the depth-based policy. Notice the sharp edges, even with really distant objects.
i.imgur.com/3hsEGXN.png
Here's MatsoDOF, which leans heavily in the "blur everything and it's grandma" policy. No sharp edges near two out-of-focus objects anymore.

On the flipside, blur-happy shaders tend to give the "focus halos" around objects.
i.imgur.com/yxnxIpO.png
Here's MatsoDOF again. Notice how the in-focus object has it's color information used for the out-of-focus blurring.
i.imgur.com/u22AORq.png
And finally here's RingDOF, in which the heavy depth-based approach resolves that issue.


So, *that's* why I recommended trying different depth shaders and even fiddling with the options (bokeh can hide these sometimes).

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
6 years 7 months ago #5 by Marty McFly Replied by Marty McFly on topic Depth of Field Help
Depth of Field is by definition a scatter phenomenon. Theoretically, every pixel should spread its color into the surroundings. Pixel shaders however work in a gather system, so every Pixel has to take the color from the surroundings. Now the problem here is, you can only know if a pixel can spread its color onto the current one (based on blur radius), if you already sampled it.

So there's 2 approaches: if a pixel has a certain blur radius, just read all samples in this radius.
This means you could miss pixels farther away that have a bigger blur radius. And discard a number of pixels that cannot blur onto the current one (like in focus ones onto blurred area). But it's fast.

Then there's scatter as gather, search the maximum blur radius and discard everything that can't possibly scatter its colors onto the current pixel. This means you have to compute a big blur for the entire image and discard 99 percent of the read pixels. Accurate, but slow AF. It's what you're looking for but it'll cut your fps in half.

All DoF shaders for ReShade work with the first method. Magic DoF and Matso are multipass, where the information if a pixel can scatter color is partially lost so the blur is much more even, at the expense of bleeding artifacts around focus objects because pixels in blurred area lose the information if the in focus one should blur into the DoF area or not.

TLDR: What you want is possible, but slow as hell. All DoF shaders use some sort of tradeoff, for performance. My DoF focuses on minimizing bleeding artifacts, others just blur everything.

PS: If you lower the Bokeh Curve of mine, you get a more even blur.

Please Log in or Create an account to join the conversation.

  • Zireael
  • Topic Author
More
6 years 7 months ago #6 by Zireael Replied by Zireael on topic Depth of Field Help

Marty McFly wrote:
TLDR: What you want is possible, but slow as hell. All DoF shaders use some sort of tradeoff, for performance. My DoF focuses on minimizing bleeding artifacts, others just blur everything.

PS: If you lower the Bokeh Curve of mine, you get a more even blur.


Thanks for taking the time to write up that explanation.
Would it be too much work to create a shader, or to add some code to the existing DOF shaders in order to achieve what I was talking about?
I don't have an issue with it being slow as hell since I only use it for screenshots, could turn it into a slideshow for all I care (something I've already done by using a really high shape quality value).

Please Log in or Create an account to join the conversation.

  • FierySwordswoman
More
6 years 7 months ago #7 by FierySwordswoman Replied by FierySwordswoman on topic Depth of Field Help
At that rate you could save a screenshot of the game and the depth buffer separately and use an external image manipulator to manually add the blur.

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
6 years 7 months ago #8 by Marty McFly Replied by Marty McFly on topic Depth of Field Help
Well I could supply a scatter as gather DoF. Insane performance hog but if that's what you want... :)

Please Log in or Create an account to join the conversation.

  • Zireael
  • Topic Author
More
6 years 7 months ago #9 by Zireael Replied by Zireael on topic Depth of Field Help

Marty McFly wrote: Well I could supply a scatter as gather DoF. Insane performance hog but if that's what you want... :)


I would greatly appreciate that. :woohoo:
Thank you for your time.

Please Log in or Create an account to join the conversation.

  • Zireael
  • Topic Author
More
6 years 6 months ago #10 by Zireael Replied by Zireael on topic Depth of Field Help

Marty McFly wrote: Well I could supply a scatter as gather DoF. Insane performance hog but if that's what you want... :)

Hey just wanted to know if you were still planning to provide this DoF.
Thanks.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.