Static DoF for FO4

share shaders here
Post Reply
  • Author
  • Message
Offline
Posts: 1
Joined: 16 Dec 2015, 10:52

Static DoF for FO4

So I mainly would like to know how possible this would be, or if it would be necessary? I just want things in the distance to be blurry without having to get close to an object. Would I need to add Static DoF or could I modify the current DoF in a way to do this? I would still like to retain the ability to get close to something and have the gradual "focusing in" effect. Sorry if this is too general of a question but I am still fairly new to coding for HLSL =P

Offline
User avatar
Posts: 84
Joined: 21 Nov 2015, 14:15

Re: Static DoF for FO4

It's quite easy to implement, actually. Instead of letting the shader dynamically parse the depth texture at any given point to determine the value of Z and react accordingly, you'd just have to tell it "my focus point is at a specific Z value".

Instead of this in the original code from Boris,

Code: Select all

float2	coord=pos.xy * 0.05;
coord+=IN.txcoord0.xy * 0.05 + float2(0.5, 0.5); //somewhere around the center of screen
float	tempcurr=TextureDepth.SampleLevel(Sampler0, coord, 0.0).x;
you'd need something like

Code: Select all

float tempcurr = XXX;
with XXX being your sweet spot. I think the Z is inverted somewhere in the rest of the code so "working" values range roughly from 0,95 to 1 or something like that.

I first implemented something like that in my little tool for handpicking the focus point, but I threw it away as I didn't need it. I'd have to check if my claims are still viable though, but that's the general idea ( 2h sleep last night, I'm a little fuzzy :p )
Post Reply