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

SubViewport texture on mesh doesn't show on exported build unless render target set to update always #86258

Open
elvisish opened this issue Dec 17, 2023 · 5 comments

Comments

@elvisish
Copy link

Tested versions

4.2.1

System information

Windows 10, Vulkan, RTX 3060

Issue description

SubViewport render textures give the error in editor:

_on_start_button_down(): Viewport Texture must be set to use it.

but display correctly in-game when run from the editor. Exported builds, however, totally break and just show black textures unless the render mode is set to Always.

#55471 addressed it, but was closed. It is still an issue, but hopefully these steps are useful enough to reproduce.

Steps to reproduce

  • Add a viewport material to a mesh and add a child Subviewport node
  • set render target to something other than Always
  • see the texture works in the game run from the editor
  • export and see the texture is black in export build

Minimal reproduction project (MRP)

N/A as this is a popular enough bug without needing me to make an example.

@EvilRacer329
Copy link

EvilRacer329 commented Dec 28, 2023

Have a reliable replication of this issue. The error doesn't stop it running perfectly in debug mode, but you get the error every time you open the scene. Only workaround is to remove the ViewportTexture from the object.

@elvisish
Copy link
Author

Have a reliable replication of this issue. The error doesn't stop it running perfectly in debug mode, but you get the error every time you open the scene. Only workaround is to remove the ViewportTexture from the object.

Your exports don't run? I haven't had that problem, although some folks had issues with my Linux builds and this error appears on every, single, log so maybe it is causing some issues with running builds.

@EvilRacer329
Copy link

Have a reliable replication of this issue. The error doesn't stop it running perfectly in debug mode, but you get the error every time you open the scene. Only workaround is to remove the ViewportTexture from the object.

Your exports don't run? I haven't had that problem, although some folks had issues with my Linux builds and this error appears on every, single, log so maybe it is causing some issues with running builds.

No, it was my mistake - I'm still getting the hang of version control and I'd made another change that was breaking exports but not debug runs. Unrelated. :)

@Rindbee
Copy link
Contributor

Rindbee commented Jan 21, 2024

The error message is a separate known issue if it appears during scene instantiation.

During the instantiation of a scene, the instantiation of resources occurs before the instantiation of nodes. This may cause problems setting up resources with resource_local_to_scene enabled (especially ViewportTexture, it needs the target viewport's information).

if (p_texture.is_valid() && p_param == TEXTURE_ALBEDO) {
RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo_texture_size,
Vector2i(p_texture->get_width(), p_texture->get_height()));
}

Usually occurs when ViewportTexture is used as albedo_texture of material.

Pointing out the exported target platform will help locate another issue.

@jamie-pate
Copy link
Contributor

jamie-pate commented Apr 26, 2024

I struggled with this for a long time until I realized that local to scene was not enabled for my mesh and/or material.. if this is not checked the viewport texture will never call set_local_to_scene which is where it actually checks the viewport path and hooks up the texture for the scene.

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

No branches or pull requests

5 participants