Page 1 of 1

DoF follows Target.

PostPosted: Wed May 29, 2019 1:12 pm
by Wolfnimations
I am trying to make a camera follow a target while the depth of field adjusts to the target.
I found out that I am not able to keyframe the depth of field property (or any property) from the PBR render target object in a Unity timeline.

Is there any way i can get this to work?
Or any pointers to a script where i can set a unity object to adjust the focal depth on the PBR render target settings based on the distance of the camera to the object?

Re: DoF follows Target.

PostPosted: Wed Jun 05, 2019 11:55 am
by ChrisHekman
Yes, you will need to make a scrip.

The PBRRenderTargetComponent has a member called RenderTarget.
That class has member called Camera.

Quick dirty code:
Code: Select all
RTComp = GetComponent<PBRRenderTargetComponent>();
if(RTComp.RenderTarget)
    RTComp.RenderTarget.Camera.SetPinFloat(Octane.P_FOCAL_DEPTH, depth);

Re: DoF follows Target.

PostPosted: Wed Jun 05, 2019 12:17 pm
by Wolfnimations
ChrisHekman wrote:
Quick dirty code:
Code: Select all
RTComp = GetComponent<PBRRenderTargetComponent>();
if(RTComp.RenderTarget)
    RTComp.RenderTarget.Camera.SetPinFloat(Octane.P_FOCAL_DEPTH, depth);


Thank you for the reply. I'll pass this on to some people that i work with that know more about coding.

For any other people that also have the same question I found another workaround that might work.
-You can create a plane, parent it to the camera and give it a completely transparent material with a refraction of 1. And move that plane further and closer to the camera with autofocus enabled. This will work in a decent amount of cases, except when a different object moves in front of the middle of the screen.