-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Vulkan: SubViewports not functioning unless update mode is set to "Always" #55471
Comments
Same here. I initially figured they just weren't implemented yet, but good to hear others are having the same issue. |
@Leakbang I had the same problem (black display) until i switch the "update mode" in the "Render target" of the SubViewport to "Always". I'm not sure this fixes your problem, but maybe give it a try. |
I did try setting the "update mode" to "Always" but it didn't make any difference for me. |
Same here in 3D, |
I retried this on |
I just discovered the existence of |
Actually no, |
Just wanted to chime in here as well - setting the update mode to Always doesn't fix the issue for me either. 28174d531b |
In alpha 1, 2D subviewports seem to work, but 3D don't. The resulting texture is either all black or all magenta |
works for me |
Hm, so it seems forcing an update/resize might do the trick? Thanks for the tip... |
Yeah its looks like that the subviewport size are not setted right by the viewport container. if u do it manualy it works. |
Small hack which fix the issue:
|
I think the issues comes inside the code. The SubViewportContainer is set the size of the SubViewport (Vector2 to Vector2i) -> something here is broken |
The following line seems to do nothing: I've been trying to draw on top of my last frame to no avail. As a minimal test, I have a subviewpoint set to clearMode NEVER, with a single colorRect with the following script: func _process(delta): The result is a new rectangle every frame, rather than a rectangle being added to the render target every frame. |
I wanted to draw output of secondary Camera3D on MeshInstance3D (PlaneMesh). I wrote simple shader that maps input texture onto plane based on screen UV.shader_type spatial;
render_mode unshaded;
uniform sampler2D viewport_texture : hint_albedo;
void fragment() {
vec4 n_out4p0 = texture(viewport_texture, SCREEN_UV);
ALBEDO = vec3(n_out4p0.xyz);
} And then I assigned this shader to I've managed to make it work, but it requires all conditions to be met:
This is how viewport texture is assignedextends MeshInstance3D
@export var viewport: NodePath;
@onready var _viewport = get_node(viewport)
func _ready():
var m: ShaderMaterial = mesh.surface_get_material(0);
m.set_shader_param("viewport_texture", _viewport.get_texture())
Note: w/o 3rd workaround (i.e. when shader's |
Thanks for the workaround, I'll try it, as I still have the pink issue on my mirror mesh. |
IriaSomobu's solution works for me |
Confirming the workaround works. |
Just to update this - I'm still seeing weirdness with pink output like @sboron in the latest master as of time of posting. Setting update / clear modes doesn't seem to help. |
I noticed that if I change the |
`SubViewport` has some initialization settings of its own, but these settings are not synchronized to the `RenderingServer` when initialized, which causes some problems. Split from godotengine#62854. This is a prerequisite to resolve godotengine#55471, still need to modify `update_mode` manually, or add as a child to `SubViewportContainer` (`update_mode` is automatically set to `UPDATE_ALWAYS`). Currently, `UPDATE_WHEN_VISIBLE` has no meaning for `SubViewport`. Presumably for **visible**, `RenderingServer` has different rules, viewport needs to have a visible **rect** to be considered **visible**, while `SubViewport` has only `size` and **no** `position`, so it is not considered **visible** even if it is set to be an active viewport (`RS::viewport_set_active`).
Expanding on @Rindbee's comment, the following seemed to work:
|
For me what ended up working was deleting the shader and material off the filesystem, re-saving the scene I was working on, and ticking 'local to scene' on those same resources. Then I could assign a new viewporttexture (which was automatically local to the scene) in the shader's parameters and it worked! |
Update on this issue, it appears that the resize workaround is no longer needed since #68358 The only issue that remains here is that the update mode "When Visible" is not working. I'm looking into this now. All other update modes are working. |
This comment was marked as abuse.
This comment was marked as abuse.
I am seeing this on Mac OS Arm64 4.0.3 version of Godot. It looks like setting the texture programmatically makes it work for me actually.
|
Just adding that I am seeing this in Godot v4.2.1 stable version of Godot, on Arch Linux using the official binaries. What nvanfleet wrote seems to be a workaround for this, so it looks like the issue is something to do with using viewport textures from the scene compared to when it's programmatically added 🤷 |
Can you provide the full script example? I put this blindly into a script on the subviewport and it clearly needs more setup to work... |
Your mesh should have a material. That material should be a shader. That shader should have a uniform sampler2D with the name "portal_texture". The issue described here, is that setting it in the Engine GUI doesn't work(I.E. clicking the material and clicking the subviewporttexture youw ant), but if you pass it programmatically it does work. I haven't had the time(or a use case) to look into whether this affects other things you can pass a viewport texture to. This line of code needs to be adapted to get the correct material, and set the correct shader parameter and get the viewport texture. More information needed to point out what you're doing wrong |
I'm getting this issue as well. Godot v4.2.1 stable. Using Fedora 39 Gnome, none of the above suggestions are working for me. |
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
v4.0.dev.calinou [cf67f18]
System information
Linux KDE Neon, Vulkan, NVIDIA GeForce GTX 1050 Ti, Driver Version: 470.63.01
Issue description
I cannot seem to make Subviewports work in any shape or form. The error message
Uniforms were never supplied for set (3) at the time of drawing, which are required by the pipeline
is continuously popping up. I have tried with both 2D and 3D objects in the viewports, however none seem to work.Are others able to reproduce this effect?
Steps to reproduce
The viewport display is black and rendering the viewport as a texture will also not work.
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: