godotengine / godot

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

Vulkan: Models/surfaces randomly stop rendering if too many lights are present #70406

Closed MirceaKitsune closed 1 year ago

MirceaKitsune commented 1 year ago

Godot version

4.0 Beta 8

System information

Linux Manjaro / KDE Plasma, ROG-STRIX-RX570-O4G-GAMING

Issue description

When too many meshes or faces are being rendered, Godot will sometimes stop drawing them for no explanation. This appears to happen more frequently the more lights you have in the scene: Toggling some lights will make the issue occur and surfaces to disappear the moment a light turns on.

Here are some screenshots from the new tileset generator I'm currently playing with: You should not be seeing any gaps, yet parts of the wall randomly disappear as you walk around. Once more the issue increases in frequency if I add more lights or increase the radius of existing ones. Note that this isn't yet a public project at least this tileset, if you need a clear test case let me know... I presume I may not need to provide one as in my case I'm experiencing it in literally every project as long as enough meshes are on the screen.

1671418116-65542-screenshot-20221219-020616 1671418117-30447-screenshot-20221219-020652 1671418114-250684-screenshot-20221219-020354

Steps to reproduce

Harder to say as different setups seem to trigger this: I tried making a simple test case with a lot of meshes and lights, but that one never caused the issue to occur. For this reason I packed the project I am getting it with attached below.

Minimal reproduction project

I've included a minimal version of my 3D tileset generator: It's already on Github except without the scenes, this one includes the models and scenes (from OpenGameArt, CC0) which trigger this issue.

Just load up the project and press F5 to run it. If you spawn outside you may need to repeatedly press to jump in mid-air and go up, the ceiling has no collisions for testing purposes so you can keep jumping until you land inside a corridor.

Tilesets.zip

Calinou commented 1 year ago

Related to https://github.com/godotengine/godot/issues/68274.

Can you reproduce this with occlusion culling disabled in the project settings?

MirceaKitsune commented 1 year ago

Related to #68274.

Can you reproduce this with occlusion culling disabled in the project settings?

It seems I can. Disabled occlusion culling and even restarted Godot afterward to be extra sure: Starting my example up again, meshes continue to disappear in large quantities.

Screenshot_20221221_194544

Megalomaniak commented 1 year ago

image

Ryzen R5 1600, Radeon RX 6600XT Manjaro KDE Plasma-wayland, Testing branch. Godot 4 beta 9

I see no occlusion culling in project settings. edit: found it, really don't appreciate the hiding feature, but eh there are a lot of them i guess.

With culling off it becomes worse: image

MirceaKitsune commented 1 year ago

Thanks for confirming. Yes I saved my test case with culling enabled, toggle it from the project settings to compare. In case any extra data helps this is the official page of my graphics card model: ROG-STRIX-RX570-O4G-GAMING

MirceaKitsune commented 1 year ago

More things I noticed with another project, similar dungeon generator but you have a flashlight you can toggle:

It appears that whenever a light turns on, random meshes within radius of that light will disappear. They remain disappeared forever even if you turn the light back off if they were initially touched by it. Turning the light off and back on repeatedly causes more objects to disappear each time.

What's notable is it never seems to be independent faces of a mesh derendering but the entire object: Everything that goes missing is one mesh instance. Seemingly with all materials at the same time, as can be seen in the screenshots from my test where each square goes missing regardless the color of different components.

unfa commented 1 year ago

I am experiencing the same problem in my game. I did not realize this is linked to lights, but it makes sense - when I added more light sources because of projectiles and impact effects - this has become more frequent.

Here's a moment where a mesh (CSG) disappears right in front of me during a game: https://youtu.be/pkvn9qiNNdg?t=279

clayjohn commented 1 year ago

I've tried out the MRP, I can't reproduce the issue on my intel integrated GPU so I will have to try again with a dedicated GPU and see if I can reproduce it there

Megalomaniak commented 1 year ago

@clayjohn I'm confident this is AMD only issue. Might even be a specific radeon driver under linux.

edit: clad to be wrong, might make it higher priority.

Calinou commented 1 year ago

I can reproduce this on 4.0.beta 621e32971 (Linux, GeForce RTX 4090 with NVIDIA 525.60.11).

This occurs sporadically across project runs, likely because the level layout is randomized on every start. When attempting to fix this bug, I recommend setting a fixed seed in a script until you can find a level layout that reproduces the issue every time.

Warning: The video below has some flashing lights due to intense specular flickering.

https://user-images.githubusercontent.com/180032/213831307-9d49cc94-3bfd-4fab-be8a-447973c6c951.mp4

Decreasing Rendering > Limits > Spatial Indexer > Threaded Cull Minimum Instances to 32 in the advanced Project Settings will reproduce the issue more consistently and more often:

image

In contrast, increasing it to 65536 avoids the issue entirely by not using the threaded cull code in the first place.

MirceaKitsune commented 1 year ago

Thank you for confirming, indeed the exact same thing I get. And yes I get the flickering too: I remember it started happening when I enabled clearcoat on the material, might be worth looking into as it's a possible bug with its shader.

myaaaaaaaaa commented 1 year ago

This seems to have been fixed by #71705 , are you guys still experiencing this in the latest beta 16?

Calinou commented 1 year ago

I can't reproduce this on 4.0.beta15 and later (with Rendering > Limits > Spatial Indexer > Threaded Cull Minimum Instances decreased to 32 in the Project Settings for better reproducibility), closing.

4.0.beta14 is the last beta to exhibit the issue.

MirceaKitsune commented 1 year ago

I no longer seem to be getting it either with Beta 17 so I think it's been resolved. Thank you for the fix.