SaschaWillems / Vulkan-glTF-PBR

Physical based rendering with Vulkan using glTF 2.0 models
MIT License
961 stars 130 forks source link

Two-sided triangles or depth issue #52

Closed tigrazone closed 2 years ago

tigrazone commented 2 years ago

Please look at video and how to fix these artifacts? I want to use objects like "solid" and I want it all visible, not lost on some depth https://youtu.be/fNzigld0rLY

LudwigFriedmann commented 2 years ago

I think your problem is called frustum culling :) The frustum is the volume of the virtual world that you're able to see. Everything else is clipped for the sake of better performance and in order to prevent unwanted effects. The frustum originates at the observer's eye or camera and is defined by vertical/horizontal opening angles, a near plane and a far plane. To solve your problem, you may have to adjust the near/far plane distance. Be careful though - this will induce optical effects.

SaschaWillems commented 2 years ago

Exactly. This is not an issue per see, but expected behaviour. The scene is clipped at the near plane. If you want to avoid that you could scale the model, move the near plane closer to the camera (note that you'll loose depth precision with this) or implemented inverted depth.

tigrazone commented 2 years ago

Ok. Where is in code and how to fix it?

SaschaWillems commented 2 years ago

Near and far clipping planes are defined in the [camera perspective]((WWP L 8IK-2 ) setup. Before you blindly change the near plane to a very small value, you may want to read up on possible implications and why it may not be the best idea to just use a small near clipping plane value.

SaschaWillems commented 2 years ago

Just a quick note: As this is not an issue per-se with the project, it might be better to ask this in the discussions tab of the project.