Invisible Label with Dynamically Created Sprite3D and SubViewport using C++

Godot Version

4.4.1

Problem

1. Problem Description:

Hello everyone,

I am encountering an issue with a dynamically created Sprite3D that contains a SubViewport where a Label is supposed to be displayed. Interestingly, a manually created setup with the same node structure works perfectly.

2. What I Have Tried So Far:

  • I verified the visibility of all relevant nodes (Sprite3D, VBoxContainer, HBoxContainer, Label). All of them are marked as visible.
  • I checked the positions of the nodes, and they are within the camera’s view.
  • The SubViewport settings are configured as follows:
    • set_update_mode(SubViewport::UPDATE_ALWAYS)
    • set_clear_mode(SubViewport::CLEAR_MODE_ALWAYS)
    • set_transparent_background(true)
  • I ensured the order of adding nodes is correct, and all properties are set before adding them to the scene.
  • A static label outside the SubViewport renders as expected.

3. Code Example:

Here was a minimal example that reproduces the issue:

4. Expected Behavior:

The label should be visible within the generated SubViewport.

5. Actual Behavior:

The label is invisible at runtime. There are no error messages in the console.

6. Question:

Does anyone have an idea why the label is invisible at runtime, even though the same structure works fine in a manually created setup? Are there any known issues with dynamically created SubViewport nodes or Sprite3D?

Thank you in advance for your help!

You should just use the Viewport.get_texture() directly to get the viewport’s texture.

Also, there’s already a Label3D node

1 Like