Visibility layer / cull mask broken ?

Godot Version

4.5.1

Question

Hi ! Subviewports with a cull mask set at 5 should only display items with visibility layers set at at least 5 right ?

That doesn’t work in my game (try to display only 2 sprites - Terrain and Player set to 1 and 11- for the minimap set to 11) so I did this test:

Did a scene with 3 colorRect, one with layer 1, the second with layer 1 and 2, the third one with layer 2. Then created a second scene with a subviewport and instanciated the rectangles scene inside.

Cull Mask = all layer, all rectangles shown.

Cull mask 1 and 2, all rectangles shown.

Cull Mask 1, only first two rectangles shown (as expected).

Cull mask 2, nothing displayed (expecting third rectangle to show).

Am I missing something ?: )

Thx for your help !

For CanvasItem.visibility_layer to work the node and all its parents need to be in the same layer as explained in the documentation:

[…] A Viewport will render a CanvasItem if it and all its parents share a layer with the Viewport’s canvas cull mask.

So you need to set the parent node visiblity_layer to 1 and 2 too for the 3rd subviewport to show the 2nd and 3rd ColorRect

1 Like

So in the end, the root of any scene that uses visibility layers needs to have all the corresponding layers ticked ?

All the parent chain up to the root (the node under the SubViewport node)

1 Like

I guess it must have its uses but man… that is overcomplicating things… per item was way more easy to handle for most cases :sweat_smile: