+1 vote

When i gettexture() on my Viewport and attach it to a Sprite then I have the scene rendered two times (one on the Sprite and one from Viewport rendered on screen).
If I hide ViewportContainer after I get
texture() then the texture is empty.
So far my only workaround is to set position of ViewportContainer somewhere off-screen.

This is my code:

$ViewportContainer.rect_position = Vector2(-1000, 0)
var viewport_texture = $ViewportContainer/Viewport.get_texture()
$Sprite.texture = viewport_texture

The reason I'm doing so is because I want to apply a custom shader on viewport texture. My way to do multipass shader, because there is no multipass shader in Godot.

in Engine by (35 points)
edited by

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.