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

Vulkan: Random meshes vanish in large scenes with lights that have a projector texture #68274

Closed
Tracked by #57284
DAShoe1 opened this issue Nov 4, 2022 · 7 comments · Fixed by #71705
Closed
Tracked by #57284

Comments

@DAShoe1
Copy link

DAShoe1 commented Nov 4, 2022

Godot version

4.0.beta3

System information

Windows 11, AMD Vega64 Driver 22.8.1, Vulkan

Issue description

When a scene has a large number of MeshInstance3D nodes (more than 980 in the MRP) and a Spotlight3D or Omnilight3D with a projector texture is added to the scene and moved around, Godot will randomly stop drawing meshes. Reloading the scene will restore them. This occurs within the editor as well as at runtime.

light_projector_bug.mp4

Steps to reproduce

  • Add at least 980 MeshInstance3D nodes with a BoxMesh.
  • Add a Spotlight3D or Omnilight3D, enable shadows, and assign a texture to the projector.
  • Move the light around the scene.

Minimal reproduction project

Light_Projector_Test.zip

@Calinou Calinou added this to the 4.0 milestone Nov 4, 2022
@Calinou Calinou moved this to To Assess in 4.x Priority Issues Nov 4, 2022
@Calinou Calinou changed the title Random meshes vanish in large scenes with lights that have a projector texture. Vulkan: Random meshes vanish in large scenes with lights that have a projector texture. Nov 4, 2022
@Calinou
Copy link
Member

Calinou commented Nov 4, 2022

I can confirm this on 4.0.beta 282e50a (Fedora 36, Radeon RX 6900 XT with RADV). This only occurs on Vulkan Clustered, not Vulkan Mobile. Increasing Max Clustered Elements to 2048 in the advanced Project Setting doesn't improve the situation.

After moving the light for a while, cubes start to disappear more slowly. It eventually stabilizes to something that looks like this:

image

@73v3
Copy link

73v3 commented Nov 5, 2022

I'm seeing almost identical behaviour in my project on Beta 4 (Windows 10. NVIDIA GTX 2070 super) Vulkan mobile forward_plus.

Moving the player causes random tiled meshinstance3Ds to vanish.

Behaviour stops when I:

  • move the tiles further away from player
  • turn off the omni light on the player
  • drop the number of 3d tiles in the scene.

I'm not using a projector texture. Just a vanilla omnilight3d.

Sorry to barge into your thread but it looks like the same issue and may help clarify the underlying bug.

Project (20Mb, sorry)

VanishingMeshes.zip

@Calinou
Copy link
Member

Calinou commented Nov 5, 2022

@73v3 Your issue occurs when using Vulkan Mobile, so it is unrelated. Please open a separate issue with the minimal reproduction project attached.

@73v3
Copy link

73v3 commented Nov 5, 2022

Apologies. Renderer was actually set to forward_plus. Switching to mobile fixes the issue.

@dzil123
Copy link
Contributor

dzil123 commented Nov 5, 2022

I'm getting this error when closing the editor after observing the behavior:

ERROR: Pages in use exist at exit in PagedAllocator: N33RendererSceneRenderImplementation22RenderForwardClustered32GeometryInstanceSurfaceDataCacheE
   at: ~PagedAllocator (./core/templates/paged_allocator.h:140)

@clayjohn
Copy link
Member

clayjohn commented Nov 9, 2022

It looks like the issue is coming from here:

void RenderForwardClustered::GeometryInstanceForwardClustered::set_softshadow_projector_pairing(bool p_softshadow, bool p_projector) {
using_projectors = p_projector;
using_softshadows = p_softshadow;
_mark_dirty();
}

_mark_dirty() is called which frees the surface data, but then for some reason, the surface isn't being reallocated. This will take a bit of investigation to figure out.

We need to check why the surface isn't being reconstructed in some cases (it appears totally random, so maybe some undefined behaviour has snuck in).

@Calinou Calinou changed the title Vulkan: Random meshes vanish in large scenes with lights that have a projector texture. Vulkan: Random meshes vanish in large scenes with lights that have a projector texture Dec 21, 2022
@clayjohn
Copy link
Member

Looks like this is caused by the multithreaded culler which is only activated if the number of instances is a scene is greater than 1000. The threshold is configurable, so it can be increased to avoid this issue in the meantime

rendering/limits/spatial_indexer/threaded_cull_minimum_instances can be increased, as long as it is larger than the number of elements in the scene this issue should go away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
5 participants