How to render background material or skybox below everything else?

Hello there!

I am trying to get the background material of my skybox to render below everything in my scene and I didn’t have much luck right now.

First I tried setting the rendering group id to be -1 so that it would be drawn first. However it doesn’t get rendered at all (yet setting the rendering group id to 2 works if I want to draw it above everything else).

Then I thought about disable the depth write, but it did not work again:

What is the Babylon way of doing that? I know increasing the size of the skybox to some extent can work (but then z-fighting can become an issue), I really just want to draw it below everything like it is the clear color or something ^^

By default, rendering group ids go from 0 to 4. You can change the MIN_RENDERINGGROUPS and MAX_RENDERINGGROUPS properties in RenderingManager to modify this range.

So, if you set MIN_RENDERINGGROUPS = -1, you will be able to set the renderingGroupId property of the skybox to -1 without changing the renderingGroupId of the other meshes:

1 Like

Ah thank you, I didn’t know about that :slight_smile: Is there a practical reason to limit the range like this? Something to do with performance maybe?

Thanks a lot it works perfectly :ok_hand:

Yes, we loop over the [min,max] range, so the fewer iterations the better.

1 Like