Camera rotation not seeming to affect Volumetric LightScattering mesh even though its a child?

I have been experimenting with setting my camera as the parent to the volumetric light scattering mesh but I cannot seem to get it to stay in the same place when my camera rotates. If I do the same actions with a box it does. Is there something I’m doing wrong here / misunderstanding?

Edit - forgot the PG code:

// You have to create a function called createScene. This function must return a BABYLON.Scene object
// You can reference the following variables: scene, canvas
// You must at least define a camera

var createScene = function() {
	var scene = new BABYLON.Scene(engine);
	var camera = new BABYLON.UniversalCamera("Camera", new BABYLON.Vector3(0, -10, 0), scene);
	camera.attachControl(canvas, true);

    // Create the "God Rays" effect (volumetric light scattering)
	var godrays = new BABYLON.VolumetricLightScatteringPostProcess('godrays', 1.0, camera, null, 100, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false);
	godrays.mesh.position = new BABYLON.Vector3(-3, 0, 3);

    // why does this not seem to rotate with the camera???
    godrays.mesh.position = new BABYLON.Vector3(0,0,3);
    // just for reference
    var box = BABYLON.MeshBuilder.CreateBox("box", {});

    // rotates with camera
    var box2 = BABYLON.MeshBuilder.CreateBox("box2", {});
    box2.position = new BABYLON.Vector3(0,0,3);

    return scene;

Perhaps there is a better answer, but I generally parent both my camera and my mesh to a parent gizmo… which will then rotate both.


Pinging @julien-moreau who created that effect

Thanks for reporting! Checking ASAP
The default mesh for volumetric lights post process is a plane with a billboard mode (ALL x y and z). Have you tested with the cube being the light emitter instead of the plane?

I haven’t tested with a cube as the emitter, however I have applied this to other meshes without an issue. If I get time today, I’ll create a playground scene using a cube as the emitter.


1 Like

I don’t know if this is what you’re asking, but here is a simple playground scene with a cube as the emitter. I can attach to a moving camera if that’s what you are asking.


I think I know what you’re asking, and will try and build this in the afternoon. I’ll try and replace the billboard with a cube, although I don’t believe this is what the initial question was. @Num_T was using a standard VLS billboard and wanted to parent this to the camera. But it would be interesting to use a different mesh as the emitter.


@Num_T found that the issue comes from the fact the mesh has a billboard mode. Just removed the billboard mode in this playground

Billboarding is computed according to the camera. I think that having a billboarded mesh child of the camera creates a cycle and generates wrong values.

@Deltakosh do you confirm? Thanks!

1 Like

Yes totally

1 Like

This is a little more interesting. The cube is the emitter and parented to the camera. However, it appears there is no way to avoid billboard mode even if it is not set. I can’t seem to create a true volumetric light.


Asked an answered :wink: Very comprehensive - thanks all!