Bug when drawing background material beneath volumetric light

Hello everyone!

I found a bug (I think?) when changing BABYLON.RenderingManager.MIN_RENDERINGGROUPS in order to draw some mesh behind eveything else when VolumetricLightScatteringPostProcess is involved:

When assigning a BackgroundMaterial to an object with group id of -1, there is a WebGPU crash in the console. It does not happen with StandardMaterial and it does not happen when I don’t touch BABYLON.RenderingManager.MIN_RENDERINGGROUPS :thinking:

Let me know if you have any idea what is happening :slight_smile:

cc @Evgeni_Popov (please be patient, he is on vacation!)

1 Like

I do not think it is related to rendering groups: ффыв | Babylon.js Playground

You already have an error in webgl;

The system swallows it but it will break webGPU for sure as it is far more fragile than webGL

Can you try to fix that error and see how it goes with WebGPU ?

Ok we have a bug in the VolumetricLightScatteringPostProcess:
ффыв | Babylon.js Playground (this one works because I disable the god rays)

If @Evgeni_Popov cannot check it by end of week I will look at it :wink:

Wait lol
why does this one work?
ффыв | Babylon.js Playground

Ok the problem comes from the BackgroundMaterial. If I comment it, it works again:

cc @sebavan : any idea?

it is linked to the interaction between BackgroundMaterial and the god rays

I will have a look this afternoon

2 Likes

@CrashMaster in any case what you wanted to achieve will not work because the god rays will also apply to the underlying background material. The idea here is to have 2 scenes and render the first scene with only the background material and then the main scene

And I found the reason why it crashes :seven_o_clock:
The VolumetricLightScatteringPostProcess only works with Standard and PBR material (because it assumes certain properties like diffuseTexture for instance)

So here is a fix for you:
ффыв | Babylon.js Playground

2 Likes

Thanks for looking into it :heart: I did not catch the warning on the WebGL side, my bad haha

Does it mean I could also use a StandardMaterial instead of a BackgroudMaterial? It looks like a possible solution:

I guess StandardMaterial is a bit slower than BackgroundMaterial but at least I don’t have to sync cameras between scenes, which adds quite a bit of complexity ^^’ I assume Frame graphs will make this easier in the future as well!

standard is fast to be honest so if that works for you go for it!!

Good to hear, I think I will go with it then.

Just out of curiosity, why is there no error when the renderingGroupId is not -1? Do the godrays just ignore the skybox in that situation?

This does not work for me. Does it for you? I have the same error (which is expected)

1 Like

This does not for me either (just to confirm)

1 Like

My bad it does not work either :laughing: (I was not having the WebGL warning so I thought it was OK but it is crashing in WebGPU).

So StandardMaterial it is! Thanks for your help :wink:

1 Like

Bonus answer: you can also exclude the mesh with the background material from the godrays like so (see L373):