If a scene instances another scene with "Editable Children" enabled, and the child scene contains a SubViewport, and a material rendering that SubViewport, the material's "Viewport Path" will be wrong. It'll render a magenta texture instead of the SubViewport. You can fix the path manually, but the editor revert to the wrong path after reloading.
Steps to reproduce
The attached subviewport_instance_tests.zip has 2 Godot projects, standard_project & shader_project. They demonstrate the same problem, using a StandardMaterial3D and a ShaderMaterial. I tried both projects under Godot 4.0.4 & 4.2.1 and got the same results all 4 times.
The MeshInstance3D displays the SubViewport. Running scene A (open a.tscn in the editor > right click the "a" tab > "Play This Scene") works as expected - "A" appears on the MeshInstance3D.
Scene B instances A:
B
├ Camera3D
└ A
Running scene B also works as expected.
Scene C is exactly like B, except C's A instance has "Editable Children" enabled. In C, the MeshInstance3D shows a solid magenta texture, and there's an error, "ViewportTexture: Path to node is invalid".
It seems that "Editable Children" causes the ViewportTexture's viewport_path to be interpreted as an absolute path from the root (the C node).
I tested this with scene D. D is like C, except I added a SubViewport at that absolute path:
D
├ Camera3D
├ A
└ SubViewport
├ Camera3D
└ Label3D (text = "D")
Playing scene D, A's MeshInstance3D shows "D", not "A".
We can fix scenes C and D manually:
Select the MeshInstance3D.
In the inspector, go to "Geometry" > "Material Override" > "Albedo" > "Texture"
change "Viewport Path" from "SubViewport" to "A/SubViewport".
Run the scene.
Now C and D work as expected. But this only helps temporarily - certain combinations of opening, saving, & closing cause the viewport_path to revert. It's a bit hard to repro, but this sequence seems to trigger it pretty reliably:
Do the manual fix on scene C.
Save & close the whole project.
Reopen the project.
Close scene A.
Reopen scene A.
Save the whole project again.
Return to scene C. The texture is magenta again, and "Viewport Path" has reverted to just "SubViewport".
You can try the same steps in shader_project and get the same result. The ViewportTexture is a uniform named tex. You can fix tex in the material inspector, but it also gets reverted.
Tested versions
reproduced in 4.0.4.stable & 4.2.1.stable
System information
Godot v4.2.1.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Fri, 05 Jan 2024 16:20:41 +0000 - Tty - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (nvidia; 545.29.06) - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 Threads)
Issue description
If a scene instances another scene with "Editable Children" enabled, and the child scene contains a
SubViewport
, and a material rendering thatSubViewport
, the material's "Viewport Path" will be wrong. It'll render a magenta texture instead of theSubViewport
. You can fix the path manually, but the editor revert to the wrong path after reloading.Steps to reproduce
The attached
subviewport_instance_tests.zip
has 2 Godot projects,standard_project
&shader_project
. They demonstrate the same problem, using aStandardMaterial3D
and aShaderMaterial
. I tried both projects under Godot 4.0.4 & 4.2.1 and got the same results all 4 times.Consider
standard_project
. Scene A has:The
MeshInstance3D
displays theSubViewport
. Running scene A (open a.tscn in the editor > right click the "a" tab > "Play This Scene") works as expected - "A" appears on theMeshInstance3D
.Scene B instances A:
Running scene B also works as expected.
Scene C is exactly like B, except C's A instance has "Editable Children" enabled. In C, the
MeshInstance3D
shows a solid magenta texture, and there's an error, "ViewportTexture: Path to node is invalid".It seems that "Editable Children" causes the
ViewportTexture
'sviewport_path
to be interpreted as an absolute path from the root (the C node).I tested this with scene D. D is like C, except I added a
SubViewport
at that absolute path:Playing scene D, A's
MeshInstance3D
shows "D", not "A".We can fix scenes C and D manually:
MeshInstance3D
.Now C and D work as expected. But this only helps temporarily - certain combinations of opening, saving, & closing cause the
viewport_path
to revert. It's a bit hard to repro, but this sequence seems to trigger it pretty reliably:You can try the same steps in
shader_project
and get the same result. TheViewportTexture
is auniform
namedtex
. You can fixtex
in the material inspector, but it also gets reverted.Minimal reproduction project (MRP)
subviewport_instance_tests.zip