Procedural Mesh in Subviewport does not render

Godot Version

Godot 4.6.1 mono with C#

Question

I’m using SurfaceTool to procedurally generate a simple wedge shaped mesh using C#. I have an orthographic camera set up to nicely frame the object with some simple lighting and a flat quad mesh under it as a floor/backdrop. This scene renders exactly how I want it to as a regular scene, but I want to use it to generate an icon to put on a button using a Subviewport. However, the moment I move all the nodes over to be children of the Subviewport, for some reason my procedural wedge mesh disappears. The flat quad floor and lighting still renders just fine in the Subviewport, I can even toggle nodes on and off to see them update in realtime, but for some reason my procedural mesh does not render. I’ve confirmed that it is positioned correctly (at least it was in the original scene) and I’ve checked in the Remote view to confirm that the nodes procedurally created by my script are there in the scene tree, so I’m at a loss at how to further narrow down what is happening here.

Nevermind, figured it out 5 minutes after posting. I did not have a SubViewportContainer added yet, so I was testing by looking at the what the SubViewport was rendering in the inspector preview. But my C# script is not a toolscript, so the procedural mesh doesn’t actually exist yet in the preview of the SubViewport shown in the inspector. This was made more confusing to me by the fact that I was running the game with the game window docked inside the Godot editor and could see my procedurally generated nodes in the Remote view, but not see them rendered in the inspector. The moment I added a SubViewportContainer and ran it again I saw my generated mesh inside the actual UI element running in the game.

2 Likes