Subviewport camera documentation

Godot Version

4.5.1

Question

I’ve been trying to figure out subviewports, and I was looking at this article in the documentation:

Which says this about what cameras will actually draw in viewports:

CameraA will display on the Root Viewport and it will draw MeshA. CameraB will be captured by the SubViewport along with MeshB. Even though MeshB is in the scene hierarchy, it will still not be drawn to the Root Viewport. Similarly, MeshA will not be visible from the SubViewport because SubViewports only capture nodes below them in the hierarchy.

Where CameraA and MeshA are direct children of the root Node3D. CameraB and MeshB are children of the subviewport, which is a child of the root Node3D.

I’m reading this as CameraA will only draw the stuff that’s not under the subviewport, and CameraB will only draw the stuff that is under the subviewport.

But when I tried building this, both cameras will render all meshes in the hierarchy. The subviewport will even draw meshes in neighboring subviewports. For context, I displayed the subviewport on a TextureRect as a child to the root Node3D.

Am I just misunderstanding this or does the documentation need to be updated?

You need to create World3D resource and assign it to viewport’s world_3d property in order to “separate” visual instances that are parented under the viewport. It’s covered later in the “Worlds” section in the document you linked:

I see!

I do think the example in the docs could be made a little bit clearer then since they haven’t really mentioned worlds yet at that point. I might throw something up on their github later.

But it makes sense to me now, and I got my example working. Thanks!

1 Like