Adjusting LensRenderingPipeline dof_focus_distance at runtime

Hi,

I have a large scene that allows for panning, rotating and zooming around a construction site. As a user zooms in and out, I want to be able to modify the dof_focus_distance of the lens effect so that the target of the camera always stays in focus.

I have tried modifying this via:

camera.onViewMatrixChangedObservable.add(function(c) {
    lensEffect.setAperture(c.radius);
})

I’ve added these lines into the example provided in the Babylon docs to demonstrate the lack of change to the focus distance.

PG: https://playground.babylonjs.com/#DX6AV#109

To answer my own post, ended up getting ina muddle with the different parameters available. Should have been using:

lensEffects.setFocusDistance(c.radius);
1 Like