I'd like to proceduraly generate a texture that I then pass in as a texture to another shader.
To try and figure this out, I've been reading https://docs.godotengine.org/en/latest/tutorials/viewports/custom_postprocessing.html.
My scene hierarchy look like:
-Node2D
-ViewportContainer
-Viewport
-MeshInstance
-Camera
-ColorRect
I've added this shader to my ColorRect, which is correctly displaying the scene I crated in the Viewport:
shader_type canvas_item;
uniform sampler2D ViewportTexture;
void fragment(){
COLOR = texture(ViewportTexture, UV);
}
However, I am unable to render anything at all for any shader that I assign the ViewportContainer. Even a simple shader that just returns the same color for every pixel displays nothing. According to the article, I was expecting the ViewportContainer to draw itself in the same way at the ColorRect, but with the Godot engine automatically supplying the TEXTURE uniform.
Is there any way to get ViewportContainer to draw? Do I even need it? It seems I could leave it out and just have my ColorRect read directly from the Viewport.