Rendering groups and depth handling with transparent effects – best practice?

I’m developing a cinematic animation in Babylon.js following ʻOumuamua, the first known interstellar object discovered passing through our Solar System in 2017.

The scene visualizes its journey past the Sun, with planets and their orbital paths in the background. As ʻOumuamua moves away, its 3D model gradually transforms into a glowing point with a luminous trail.

The issue

I wanted ʻOumuamua, including its 3D mesh, glow and trail, to render in front of the planets’ orbital paths while still disappearing naturally behind the Sun during its flyby.

However, changing rendering groups sometimes caused unexpected results. Elements either appeared behind the orbital paths or incorrectly rendered in front of the Sun.

What I’ve tried

I eventually achieved the desired result using:

  • Rendering group 1 for the orbital paths.

  • Rendering group 2 for ʻOumuamua, its glow and trail, and the Sun.

This works visually, but getting there involved considerable trial and error.

My question

Is this the recommended approach in Babylon.js, or is there a better way to manage rendering order while preserving correct 3D occlusion, especially when combining opaque meshes and transparent effects?

I’m interested in understanding whether my current solution follows Babylon.js best practices or if there are potential issues I should be aware of.

You can see the sequence here - ʻOumuamua — Interstellar Passage

your setup works, but the groups arent doing the part you probably think they are. the sun occludes the glow because its opaque and wrote depth, and the glow still depth tests even in a higher group, it just shouldnt write depth itself. cleaner split is sun and planets opaque in group 0, paths group 1, glow and trail group 2, all the transparent stuff depth write off. i put the fuller breakdown, including the two traps that usually cause the trial and error, here: https://vectle.com/skills/skl_lqLJmld9vUNzWeIQVhEUfA

Thanks @rachelwilson for taking the time putting together and creating such a detailed explanation. Really appreciate it!

Your breakdown of rendering groups, depth testing- and writing helped clarify a few things. One aspect I find interesting is how Babylon.js handles depth buffer clearing between rendering groups, since that seems important when you want transparent effects to respect opaque geometry.

It’s useful to understand not just what works, but why, and what the approach should be.

Thanks for sharing your insights!

Yeah, I ran into this exact headache working on a space scene with particle trails and planets. Turning off depth writing on your transparent layers is honestly the main trick that saves your sanity, otherwise closer objects still act weird with the depth buffer even if they’re in a higher rendering group.