fix(rendering): enable backface culling for one-sided M2 materials (#57)

All M2 pipelines used VK_CULL_MODE_NONE, so back-facing polygons always
rendered.  On NPCs whose torso meshes are single-layer geometry this
made the interior cavity visible through the back.

Create backface-culled pipeline variants (VK_CULL_MODE_BACK_BIT) and
select them at draw time unless the material has the TwoSided flag
(0x04).  Foliage/ground-detail forceCutout batches and the shadow
pipeline keep VK_CULL_MODE_NONE since those cards are inherently
two-sided.
This commit is contained in:
Kelsi 2026-04-06 18:18:05 -07:00
parent f79110cb14
commit 7b746a3045
3 changed files with 48 additions and 10 deletions

View file

@ -394,11 +394,16 @@ private:
// Vulkan context
VkContext* vkCtx_ = nullptr;
// Vulkan pipelines (one per blend mode)
// Vulkan pipelines — two-sided (VK_CULL_MODE_NONE) variants
VkPipeline opaquePipeline_ = VK_NULL_HANDLE; // blend mode 0
VkPipeline alphaTestPipeline_ = VK_NULL_HANDLE; // blend mode 1
VkPipeline alphaPipeline_ = VK_NULL_HANDLE; // blend mode 2
VkPipeline additivePipeline_ = VK_NULL_HANDLE; // blend mode 3+
// Backface-culled variants for one-sided materials (materialFlags & 0x04 == 0)
VkPipeline opaqueCulledPipeline_ = VK_NULL_HANDLE;
VkPipeline alphaTestCulledPipeline_ = VK_NULL_HANDLE;
VkPipeline alphaCulledPipeline_ = VK_NULL_HANDLE;
VkPipeline additiveCulledPipeline_ = VK_NULL_HANDLE;
VkPipelineLayout pipelineLayout_ = VK_NULL_HANDLE;
// Shadow rendering (Phase 7)