Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewport data not being sent to shader parameter in runtime #16006

Closed
AssjackGames opened this issue Jan 23, 2018 · 8 comments
Closed

Viewport data not being sent to shader parameter in runtime #16006

AssjackGames opened this issue Jan 23, 2018 · 8 comments
Assignees
Milestone

Comments

@AssjackGames
Copy link

AssjackGames commented Jan 23, 2018

Godot version:

3.0 RC2

OS/device including version:

Windows 10
AMD Radeon HD 7700 Series
Driver version: Adrenalin (17.12.1)

Issue description:

Viewports aren't properly sending their output to shaders (at least in 2D, haven't tested for 3D). While it appears to work fine in-editor, when the scene is ran the output is all black.

Steps to reproduce:

First I created an empty scene, root type node2D. I made a viewport, set it up, and added an image under it, setting the texture to a png. I then made a new sprite outside that viewport and set the texture to the viewport output to test if it was outputting fine. I ran the scene and all seemed to work, I saw the circle image.

I then replaced the texture of the output image with a blank png (Color(1, 1 ,1 ,1)) the size of the screen, and created a new shader, using this code:

shader_type canvas_item;

uniform sampler2D mask;

void fragment(){
	COLOR = texture(mask, UV);
}

Then I set the parameter mask to the viewport output, and I saw the results immediately in the editor, however when I run the scene the output is all black. I also tried sending the viewport data through gdScript using get_texture, and it too led to the black screen output.

Minimal reproduction project:

Test project attached. I created two output sprites for it, one direct from the viewport, one with the shader. With this bug any shader needing more than a single viewport won't work.

Viewport Bug.zip

@DoctorAlpaca
Copy link
Contributor

Of note, when also using the same texture to a sprite the correct texture gets send to the shader. I'm guessing the shader handling code doesn't correctly tell the texture to update itself.

@AssjackGames
Copy link
Author

Not that it was on the agenda, just thought I'd mention that the bug exists in 3.0 stable too.

@ghost ghost added this to the 3.1 milestone Jan 31, 2018
@AssjackGames
Copy link
Author

Not sure if this is related, but when I try to set an image texture to a new ViewportTexture via gdScript (changing the viewport_texture property too of course) it shows nothing when I run it. I know the viewport works fine, and oddly enough when I make the sprite through the editor, set it to the viewport, clear the path and set the path through gdScript it shows fine too. Problem seems to be initiating a new ViewportTexture through code. Should this be a new ticket?

@AssjackGames
Copy link
Author

My tests have been completely in 2D, should that make any difference in diagnosis

@akien-mga
Copy link
Member

Related to #7998.

@kubecz3k
Copy link
Contributor

Related to #17651

@kiiada
Copy link

kiiada commented May 2, 2018

Confirming this issue exists in 3D as well.

My scene structure is:

-PlaneMesh (material settings: albedo viewport texture, transparent flag checked, billboard)
   '- Viewport (set to transparent bg, update mode to always)
       '- Control
           '-Label

As described, the label node text appears on the texture in the editor, but when a scene containing the node is run the texture is black without the label text

@reduz reduz self-assigned this Sep 6, 2018
@reduz reduz closed this as completed in 7c00f05 Nov 14, 2018
@reduz
Copy link
Member

reduz commented Nov 14, 2018

This is not a bug (Material was not set as local to scene), but usability was pretty bad to let you know what was going on.
Added warnings to avoid you when creating a ViewporTextures if most common conditions are not met instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants