Modifying the camera for custom DOF

I’m looking at creating a camera whose depth of field properties would be calculated from real life lens parameters (focal length, aperture, subject distance).

I’m thinking about having those parameters drive Focal Distance and Focal Region, so that I’m not changing the fundamentals of the camera system.

Assuming I can do this (can I ?), would I be able to see the changes live in the editor?

Hi Cedric,

Yes, you should be able to drive those parameters and see them live in PIE and (depending on how you drive them) in the camera preview inset box in the editor viewports.

On the camera component, the property PostProcessSettings controls what overrides are being applied, and what those overrides are. Set bOverride_DepthOfFieldFocalDistance and bOverride_DepthOfFieldFocalRegion to true and modify DepthOfFieldFocalDistance/DepthOfFieldFocalRegion to whatever values you calculate from your exposed parameters (in e.g., PostEditChangeProperty for the actor class containing your camera component).

Cheers,
Michael Noland

Hi Michael,

This doesn’t seem to work in Beta 5.

When creating my camera component, I do the following:

CameraComponent->PostProcessSettings.bOverride_DepthOfFieldFocalDistance = true;
CameraComponent->PostProcessSettings.bOverride_DepthOfFieldFocalRegion = true;
CameraComponent->PostProcessSettings.bOverride_DepthOfFieldScale = true;
CameraComponent->PostProcessSettings.bOverride_DepthOfFieldMethod = true;
CameraComponent->PostProcessSettings.DepthOfFieldMethod = EDepthOfFieldMethod::DOFM_BokehDOF;
CameraComponent->PostProcessSettings.DepthOfFieldScale = 1.0f;

Then I change DepthOfFieldFocalDistance and DepthOfFieldFocalRegion when required, but I don’t see any result. I can confirm that the post process settings values are actually being modified, but I don’t see any Depth of Field change in the camera preview window.

Hi Cedric,

Have you set PostProcessBlendWeight to a non-zero value? If so, is it failing to take effect only in the preview viewport, or everywhere?

Cheers,
Michael Noland

Ha thanks, I missed that property. It’s failing in the preview viewport, but works in game.