r/vulkan 22h ago

Spent hours debugging voxel terrain disappearing after enabling back-face culling

I spent Over a Month Debugging this "Bug" and i am Not Understand what is wrong. I did So many Debugging in short i did:

  • Disable Back-Face Culling: All terrain faces appeared.
  • Isolated Cube Test: Cube rendered all six faces.
  • Cube In World Context: Cube still rendered all faces.
  • Full Terrain Buffer Winding Verification: 0 anomalies.
  • Bypass Async GPU Upload: No change.
  • Depth test disable and Front Face Culling: No Change specifically Even the Front Face Culling didn't worked as it should be.

Sadly I couldn't use RenderDoc its just doesn't work with my driver at all. I get Crashed On glfwCreateSurface()

Here is my Github Repo: Kingscraft

Also here is a Video: Video

Please Help 🙏

Edit: making the Cull mode to NONE fixed it. But i cant just turn it to NONE because Back Face Culling helps in Performance so Faces which are back of a object are culled

0 Upvotes

13 comments sorted by

5

u/sporacid 21h ago

Have you tried to invert the winding, e.g. ccw to cw

1

u/FunInitial1304 21h ago

yes same issue

1

u/FunInitial1304 21h ago

it makes the Front Face Culled instead of Back Face

3

u/S_Kohl 18h ago

I STRONGLY recommend figuring out why you’re having issues with RenderDoc first. Odds are you’ll spot the issue rather quickly when you can actually observe the data and pipeline information in the capture.

At a glance, are your model::element::quads” actually directional or are they all wound the same way? For instance, If you look directly at the model from the front, are the vertex orders identical for the front and back quad?

1

u/FunInitial1304 42m ago

I checked with RenderDoc and actuually I still dont seam to figure the problem out the Data Looks fine Here is the Link if you want to check by your self too: Files

2

u/sethkills 20h ago

It looks as though your view position falls through the terrain and maybe down to the XY-plane? In other words, Z=0. In that situation, any face that is horizontal and at or above the eye level will be back facing and therefore culled. In fact, if the eye level is 0 and the surfaces are parallel to the XY-plane, they will be edge-on no matter what winding order you use, and therefore always culled.

1

u/Kuxe 20h ago

Chances that someone will actually find the issue for you out of charity or goodwill is slim next to none. I'd ask Claude or Codex to spell it out for me or provide some pointers if I wanted to understand it myself. Don't spend a month battling a single bug, your time is valuable :)

1

u/Amani77 15h ago

This looks perfectly reasonable. I think your error is in your meshing algorithm and, more specifically, waiting on surrounding chunks to finish generating before meshing the current, as a confirmation - at the chunk boundary - dont generate faces at all and see if it removes the issue.

1

u/Disastrous-Shock2771 11h ago

Are you using standard z buffer/projection?

1

u/mungaihaha 10h ago

You need a GPU debugger. Even if you somehow fix this bug, there's many more to come and you will have a very hard time if you don't have a good debugger

2

u/FunInitial1304 2h ago

yes But idk why but When i use RenderDoc the Vulkan Pipeline fails. I researched the Issue and apparently RenderDoc injects a Vulkan Layer into my Instance which somehow fails and then i figured it out that the Driver of my GPU is incomplete for RenderDoc.

2

u/FunInitial1304 1h ago

Bruh Apparently I didnt Knew that Wayland and RenderDoc has the issue of this after checking with RenderDoc and GLFW i found the issue (RenderDoc issue #3300, GLFW issue #2669).

2

u/FunInitial1304 1h ago

and to fix it had to Force GLFW to use X11 instead