LensRenderingPipeline - How do I get the current focus distance?

I don’t see anywhere in the LensRenderingPipeline API where I can get the current focus distance. (I see where I can set it, but I also need to get it for other stuff I’m doing). What am I missing?


Example - https://playground.babylonjs.com/#DX6AV#329

Thanks @labris for the fast response. Unfortunately I’m getting a TS error "Property ‘_dofDistance’ is private and only accessible within class ‘LensRenderingPipeline’. How do I get around this?

The easiest way is to put


before the line where you get a private property.

Thanks. That worked, enough. I got a new warning from eslint saying “Do not use ‘@ts-ignore’ because it alters compilation errors.” I can suppress that line too, I suppose, but now my code is:

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

Feels kinda hacky. Seems like dofDistance should just be a public property with no fuss.

Regardless, thanks @labris for the fast responses. This at least got everything working!

Looking more closely to the source - Babylon.js/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts at ed74a68355a29a0971a695c2cb605e674f71b67f · BabylonJS/Babylon.js · GitHub - I found the public getter (not easy to guess from its name what it does):

1 Like

Wow, you’re right. How…odd. There seems to be something else going on with this setting because the closer I get to a value of 10 the scene loses its color in addition to moving the focus distance. This whole pipeline is feeling really odd to me and not very usable. I’ll prob go back to the default pipeline for depth-of-field effects, or explore how to make my own.

1 Like