godotengine / godotengine/godot

SubViewport renders non-child nodes

Open
#104,516 1 comment 0 reactions 0 assignees View on GitHub
bug documentation topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: v4.4.stable.arch_linux, v4.4.1.rc2.official [abef5e0d2], v3.6.stable.official [de2f0f147]

### System information

Godot v4.4.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Thu, 13 Mar 2025 18:12:00 +0000 on Tty - X11 display driver, Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Mesa Intel(R) UHD Graphics 600 (GLK 2) - Intel(R) Celeron(R) N4120 CPU @ 1.10GHz (4 threads)

### Issue description

When rendering the contents of a SubViewport to a ViewportTexture on a material of a mesh, the SubViewport renders nodes that are not its descendants. I noticed this while trying to figure out why a SubViewport was rendering a non-child Camera3D, but I have yet to replicate that issue.

Here is the tree:
![Image](https://github.com/user-attachments/assets/154e8aaf-01c5-4f09-bb65-6bc6eac0fe94)

This behavior differs from the explanation in [the viewports documentation tutorial.](https://docs.godotengine.org/en/4.4/tutorials/rendering/viewports.html#cameras-2d-3d). It states that the SubViewport should not render MeshA, since it's not its descendant.

### Steps to reproduce

1. Create a _Node3D_ based scene and add a _Camera3D_, a _MeshInstance_ with any mesh and a _MeshInstance_ with a quad mesh. Make the quad mesh a local resource.
2. As a child of the quad _MeshInstance_, add a _SubViewport_, to which add a _Camera3D_ and a _MeshInstance_ with any mesh as children.
3. Add a StandardMaterial to the quad mesh and make it a local resource. Set the _albedo_texture_ to be a _ViewportTexture_, to which set the SubViewport as the _viewport_path_.
4. Add a _WorldENvironment_ to the scene to be able to see the texture at runtime.

A project with this setup is included as the MRP.

### Minimal reproduction project (MRP)

[bug-nonchildrenobjects_2025-03-23_11-59-19.zip](https://github.com/user-attachments/files/19408168/bug-nonchildrenobjects_2025-03-23_11-59-19.zip)

Contributor guide

Open the contributing guide

Research direction

Open the attached minimal reproduction project and follow the SubViewport, ViewportTexture, Camera3D, and MeshInstance setup described in the reproduction steps. Compare the observed rendering with the linked viewports documentation, then verify that non-descendant nodes are excluded from the SubViewport output.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.