Depth mask broken in 5.5.6?

Does anyone know what would’ve changed to stop the depth mask working? I have an example here where the depth mask on the plane allows the YouTube video (behind the canvas) to be visible https://playground.babylonjs.com/#TGZ9GN#7

The code for the depth mask starts at line 190

1 Like

@sebavan , could this be related to the material sorting on the renderer?

@ozRocker , the problem is that you are defining the rendering order by manually placing the meshes into the scene.meshes array. Due to some optimizations that were introduced in 5 it is no longer guaranteed for meshes to be drawn in the order appear in the array. However, you can override the sort function used in the scene to go back to the old behaviour by calling scene.setRenderingOrder(0, () => 0) . I’ve updated you sample with this and got it working:

Iframe | Babylon.js Playground (babylonjs.com)

You can also use the renderingGroupId property on the mesh to set the rendering order for a particular mesh you want to render first. This would allow you to keep the performance improvement of the sorting.

Here is some documentation on rendering groups:
Transparent Rendering | Babylon.js Documentation (babylonjs.com)

3 Likes

@srzerbetto you are spot on :slight_smile:

Thank you @srzerbetto
Overriding the sort function works. I tried the other method but can’t seem to get the renderingGroupId to do anything. Tried setting it to 0 and also 1 https://playground.babylonjs.com/#TGZ9GN#149