godotengine / godotengine/godot

Materials on instances using viewport textures do not properly interpret nodepaths

Open
#96,816 4 comments 1 reaction 0 assignees View on GitHub
bug confirmed topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in 4.3stable.

### System information

MacBook Air M1

### Issue description

When adding a ViewportTexture to a material on an instanced mesh scene, the ViewportTexture tries to interpret the NodePath to the SubViewport as a local path:

(in the scope of itself as the root, ie if the SV is a direct child of the mesh the path would simply be "SubViewport")

when the path is instead generated as a global/absolute path:
Screenshot 2024-09-10 at 3 14 53 PM
(in the scope of the scene owner, ie if the SV is a direct child of the mesh the path would be "MeshNode/SubViewport").

This can be temporarily fixed by manually setting the path, but any changes are reset upon scene reload.

When done with a mesh originally created in a scene, the same process occurs, but functions correctly, therefore my best guess is that a scene being instanced treats nodepaths as local by default.
Apologies if this is a duplicate or difficult to understand, this is my first issue. :D

### Steps to reproduce

1. Create a separate scene with a meshinstance3D
2. Instance that to another scene
3. Add a SubViewport child to that instance
4. Add a new StandardMaterial3D, make local to scene, add Viewport texture
5. Set subviewport as viewport in viewport texture
6. Reload scene

### Minimal reproduction project (MRP)

[MRP2.zip](https://github.com/user-attachments/files/16949879/MRP2.zip)

Contributor guide

Open the contributing guide

Research direction

Open the MRP2.zip project and follow the listed reproduction steps using MeshInstance3D, SubViewport, StandardMaterial3D, and ViewportTexture. Compare the node path behavior for an instanced mesh with one created directly in the scene. Done means reloading the scene no longer resets the ViewportTexture path to an unusable interpretation.

Written by the indexing model from the issue text.

Assessment

Domain
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.