0 votes

Take following example:

texture(SCREEN_TEXTURE, SCREEN_UV);

The resulting texture should contain the drawn tscn. However, while manipulating the Camera2D's transform, the result doesn't contain the screens content, but the pre-defined window width/height.

I wasn't able to find anything within the docs describing that the SCREENUV and SCREENTEXTURE are statically bound to the pre-defined window properties. As an ordinary person I would expect that those parameters do access what is actually drawn onto the screen.

How am I able to obtain the drawn "SCREEN_TEXTURE" the camera2D comprises?

Godot version 3.2.3.stable.official
in Engine by (28 points)

1 Answer

0 votes

I did find my mistake. My findings are following:

The SCREEN_TEXTURE does return the current drawn main cameras viewport's texture. Even if not, you could use a uniform like this:

uniform sampler2D viewport;
material.set_shader_param("viewport", _camera.get_viewport().get_texture())

Secondly, my sprite (using the shader) wasn't a child of the camera. Thus, when the camera moves, the sprite was still at (0/0), displaying the shader at the wrong location.

by (28 points)
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 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 webmaster@godotengine.org with your username.