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?
DoF follows Target.
Moderator: ChrisHekman
- ChrisHekman
- Posts: 1061
- Joined: Wed Jan 18, 2017 3:09 pm
Yes, you will need to make a scrip.
The PBRRenderTargetComponent has a member called RenderTarget.
That class has member called Camera.
Quick dirty code:
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);
- Wolfnimations
- Posts: 8
- Joined: Fri Feb 22, 2019 11:39 am
Thank you for the reply. I'll pass this on to some people that i work with that know more about coding.ChrisHekman wrote:
Quick dirty code:Code: Select all
RTComp = GetComponent<PBRRenderTargetComponent>(); if(RTComp.RenderTarget) RTComp.RenderTarget.Camera.SetPinFloat(Octane.P_FOCAL_DEPTH, depth);
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.