Welcome, Guest.
Username: Password: Remember me

TOPIC: Depth of Field Help

Depth of Field Help 7 months 3 weeks ago #1

  • Zireael
  • Zireael's Avatar
  • Offline
  • Posts: 67
  • Thank you received: 5


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: 7 months 3 weeks ago by Zireael.
The administrator has disabled public write access.

Depth of Field Help 7 months 3 weeks ago #2

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.
The administrator has disabled public write access.

Depth of Field Help 7 months 3 weeks ago #3

  • Zireael
  • Zireael's Avatar
  • Offline
  • Posts: 67
  • Thank you received: 5
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.
The administrator has disabled public write access.

Depth of Field Help 7 months 3 weeks ago #4

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).
The administrator has disabled public write access.

Depth of Field Help 7 months 3 weeks ago #5

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 980
  • Thank you received: 979
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.
The administrator has disabled public write access.

Depth of Field Help 7 months 1 week ago #6

  • Zireael
  • Zireael's Avatar
  • Offline
  • Posts: 67
  • Thank you received: 5
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).
The administrator has disabled public write access.

Depth of Field Help 7 months 1 week ago #7

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.
The administrator has disabled public write access.

Depth of Field Help 7 months 1 week ago #8

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 980
  • Thank you received: 979
Well I could supply a scatter as gather DoF. Insane performance hog but if that's what you want... :)
The administrator has disabled public write access.

Depth of Field Help 7 months 1 week ago #9

  • Zireael
  • Zireael's Avatar
  • Offline
  • Posts: 67
  • Thank you received: 5
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.
The administrator has disabled public write access.

Depth of Field Help 6 months 2 weeks ago #10

  • Zireael
  • Zireael's Avatar
  • Offline
  • Posts: 67
  • Thank you received: 5
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.
The administrator has disabled public write access.