RenderingGroup - onBeforeRender / onAfterRender

I’m grouping meshes in relevant rendering order and my wish is that before/after each group is rendered, I want set/reset some GL state functions (like Depth…) so that it’s set for a group.

Is there any option like onBeforeRenderObservable / onAfterRenderObservable for a RenderingGroup (BABYLON.RenderingManager).


You have onBeforeRenderingGroupObservable and onAfterRenderingGroupObservable on the Scene object. The callback is passed a info structure from which you can retrieve the renderingGroupId:

scene.onBeforeRenderingGroupObservable((info) => console.log(info.renderingGroupId));