DOF around player focal point

I currently have my DOF set to FOCUS_distance on my map.

I’ve had a play around with the FOCUS_position and it seems that the position gets fixed and never changes.

Does anyone know how I can change it so that the focus is on whatever the player is looking at?

Thanks in advance.

I do it every frame from code with a trace from the camera position
use Focus_Position and set the trace hitlocation

Thanks @, i’ll give it a try.

you’re welcome
err forgot to mention I do this trace on the 2D deprojected position of the center of the screen

as I use Canvas.DeProject, I call this from my Hud’s PostRender()

Good to know. May I ask how/where you set the new position for the focus DOF?

you have to access your postprocess:


theUberPP = UberPostProcessEffect(LocalPlayer(ePlayerOwner.Player).PlayerPostProcess.FindPostProcessEffect('TheNameOfTheUberPP')); // do this only once, at init
theUberPP.FocusPosition = CrosshairHitWorldLocation; // this we got already in the trace

I have a dynamic depth of field post process shader (from the old forums/links dont work anymore).If you want i can upload it for you guys but it will be in probably a week as my
gpu died and im waiting for the new one to arrive from the UK.

for me the code solution works better than a pure shader solution for the DoF focus point (even if I’m also using a custom DoF shader). the reason being that I can interpolate the FocusPoint over time rather than having instant focus changes
but for others it might be useful :slight_smile:

Nice one guys. @ I’ll give your way a shot as I also want the interpolation between focus shifts. I’m quite curious to see how it looks.

@, sorry to be a noob, but where can I find what the name of my Uber post process is? I currently have ‘none’ set under ‘World Post Process Chain’ in my map’s world info properties.

@, nevermind, i managed to get a reference to my UberPostProcessEffect in the chain.

However when I’m in game testing it out. The dof focus doesn’t follow the hit location from my trace.

I know that the trace is correct (as i’m outputting the name of what I’m looking at and it’s correct). On my map, under ‘World Properties’ I have set ‘DOF Focus Type’ to ‘FOCUS_Position’.

However the focus point just seems to be static.

I’m really not sure what I’m missing. I’m able to enable/disable the UberPostProcessEffect through my reference, so i know I’m using the active effect node.

Any ideas on why the DOF doesn’t focus on the trace targets?

Edit: I just figured out I needed to uncheck the focus position option in world properties. It seems, if checked, this has precedence.

Do you change the radius?

DOF_FocusInnerRadius

I use a multiplier based on the distance, more distace, more radius.

Or perhaps you are using the default post proccess:

worldinfo.DefaultPostProcessSettings.DOF_FocusDistance

So the issue I see with this effect is that when you focus on something some distance away, everything comes into focus from the players view point, all the way to the focal point. I would expect when focusing on a distant object, peripheral view of closer objects would blur.

Is this possible with UDK?

Yes, using the innerRadius. Give it a low value, then the near objects will blur (and the far objects too).

Thanks for the response @CobaltUDK . That is the exact fx i’m after.

I have the FocusInnerRadius set to 500 (which seems low), but still the focus extends all the way from the player’s view to the target location.

It’s a if there is a radius around the player which extends as far as the target location (where the player is looking).

Also: Yes i’m using the default pp chain.

Perhaps you have this set to 0?

DefaultPostProcessSettings.DOF_MaxNearBlurAmount = 1.000000

I did have ‘Min’ set to 0 in my Post Process Settings on my map. I’ve changed that to 1.0, but now everything is blurred…

Here are my settings in my world properties on my map:

http://content.screencast.com/users/coldscooter/folders/Jing/media/e0e245bc-6271-4d50-9c51-d8e6535c0e26/2016-09-17_1003.png

And here is the code I’m calling from my player controller to manage the focus position:



event PlayerTick( float DeltaTime )
{
    super.PlayerTick(DeltaTime);

    UpdateDynamicDof();
}

simulated function UpdateDynamicDof()
{
    local Actor hitActor;
    local vector hitLoc, hitNorm, start, end;
    local int traceDist;

    traceDist = 25000;

    if (UberPP == none && Player != none) {
        UberPP = FindUberPostProcessEffect();
    }

    if (Pawn != none && LocalPlayer(Player) != none && UberPP != none) {
        start = Pawn.GetWeaponStartTraceLocation();//Define start  and end of trace.
        end = start + normal(vector(Pawn.GetBaseAimRotation())) * traceDist; 

        hitActor = Trace(hitLoc, hitNorm, end, start);

        if (hitActor != none) {
            UberPP.FocusPosition = hitLoc;
        }
    }
}


Ah ok I see what I was doing wrong. I needed to set my MaxNear to 1.0 (as you quite rightly suggested in your last post).

Thanks so much for your help. Now I can start tweaking it to get the balance right :slight_smile: