This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+3 votes

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.

in Engine by (154 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.