VolumetricLight, .infiniteDistance and DirectionalLight

I’m trying to get a VolumetricLight to work on a mesh that has the infiniteDistance property set to true (so its position relative to the camera will always be the same, like a sun that’s very far)

however, this seems to break the VolumetricLight PP

Please see this Playground:

I’m also using a directionalLight , if that makes any difference.

(Normally I use a quite old version of babylon.js because its more lightweight and thought upgrading might fix it, but alas, it didn’t…)

cc @Evgeni_Popov

The infiniteDistance flag updates the way the world matrix is computed but does not really change the position of the mesh. However, the volumetric post process needs that the position of the mesh is the real position.

So, instead of using infiniteDistance you can move the sun in the same way infiniteDistance would do it:

2 Likes

Thanks! That solution seems so obvious that I’m almost sure I already tried that in the past (years ago when I worked on this project), but at that time it made the sun jittery/laggy, however now it seems fine. :slight_smile:
At any rate, that worked.