godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.19k stars 21.21k forks source link

Error message when sharing a world_2d between Viewports #70193

Open michasng opened 1 year ago

michasng commented 1 year ago

Godot version

v4.0.beta7.official [0bb1e89fb]

System information

Windows 10, Intel Core i7 10750H, Intel UHD Graphics, NVIDIA Quadro T1000

Issue description

When the main world_2d is assigned to a SubViewport.world_2d, this error message is printed once per frame:

E 0:00:01:0044   draw_list_bind_uniform_set: Attempted to use the same texture in framebuffer attachment and a uniform (set: 3, binding: 0), this is not allowed.
  <C++-Fehler>   Condition "attachable_ptr[i].texture == bound_ptr[j]" is true.
  <C++-Quellcode>drivers/vulkan/rendering_device_vulkan.cpp:7707 @ draw_list_bind_uniform_set()

I was trying to display parts of the world in a different position with the second viewport (which is actually working with this setup + some Camera2Ds). I was not expecting an error message here, let alone one that doesn't tell me how to solve the problem as a user.

Steps to reproduce

Create a new project with a Node2D Scene. Attach a SubViewportContainer and a SubViewport below it. Attach a script to the SubViewport with this snippet:

func _ready():
    world_2d = ($"/root" as Window).world_2d

Minimal reproduction project

test.zip

michasng commented 1 year ago

I found this related issue: https://github.com/godotengine/godot/issues/31856

And I got my example to run without error by setting the visibility layer and light mask of the SubViewportContainer to 2 and setting the Canvas Cull Mask of the SubViewport to 1.

The issue seems to be due to some recursive rendering issue. It would still be nice to have a better error message for this.

mikhaelmartin commented 3 months ago

As a temporary solution, I found that putting the SubViewportContainer under a new CanvasLayer node breaks the rendering recursion.

dalexeev commented 2 months ago

Related:

There is another workaround, without CanvasLayer: https://github.com/godotengine/godot/issues/81928#issuecomment-2337645721.