mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 00:03:50 +00:00
Revert "fix(rendering): enable backface culling for one-sided M2 materials (#57)"
This reverts commit 7b746a3045.
This commit is contained in:
parent
70a0be9e79
commit
4dcea08b90
3 changed files with 10 additions and 48 deletions
|
|
@ -394,16 +394,11 @@ private:
|
||||||
// Vulkan context
|
// Vulkan context
|
||||||
VkContext* vkCtx_ = nullptr;
|
VkContext* vkCtx_ = nullptr;
|
||||||
|
|
||||||
// Vulkan pipelines — two-sided (VK_CULL_MODE_NONE) variants
|
// Vulkan pipelines (one per blend mode)
|
||||||
VkPipeline opaquePipeline_ = VK_NULL_HANDLE; // blend mode 0
|
VkPipeline opaquePipeline_ = VK_NULL_HANDLE; // blend mode 0
|
||||||
VkPipeline alphaTestPipeline_ = VK_NULL_HANDLE; // blend mode 1
|
VkPipeline alphaTestPipeline_ = VK_NULL_HANDLE; // blend mode 1
|
||||||
VkPipeline alphaPipeline_ = VK_NULL_HANDLE; // blend mode 2
|
VkPipeline alphaPipeline_ = VK_NULL_HANDLE; // blend mode 2
|
||||||
VkPipeline additivePipeline_ = VK_NULL_HANDLE; // blend mode 3+
|
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;
|
VkPipelineLayout pipelineLayout_ = VK_NULL_HANDLE;
|
||||||
|
|
||||||
// Shadow rendering (Phase 7)
|
// Shadow rendering (Phase 7)
|
||||||
|
|
|
||||||
|
|
@ -570,14 +570,13 @@ bool M2Renderer::initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout
|
||||||
|
|
||||||
// Pipeline derivatives — opaque is the base, others derive from it for shared state optimization
|
// Pipeline derivatives — opaque is the base, others derive from it for shared state optimization
|
||||||
auto buildM2Pipeline = [&](VkPipelineColorBlendAttachmentState blendState, bool depthWrite,
|
auto buildM2Pipeline = [&](VkPipelineColorBlendAttachmentState blendState, bool depthWrite,
|
||||||
VkCullModeFlags cullMode = VK_CULL_MODE_NONE,
|
|
||||||
VkPipelineCreateFlags flags = 0, VkPipeline basePipeline = VK_NULL_HANDLE) -> VkPipeline {
|
VkPipelineCreateFlags flags = 0, VkPipeline basePipeline = VK_NULL_HANDLE) -> VkPipeline {
|
||||||
return PipelineBuilder()
|
return PipelineBuilder()
|
||||||
.setShaders(m2Vert.stageInfo(VK_SHADER_STAGE_VERTEX_BIT),
|
.setShaders(m2Vert.stageInfo(VK_SHADER_STAGE_VERTEX_BIT),
|
||||||
m2Frag.stageInfo(VK_SHADER_STAGE_FRAGMENT_BIT))
|
m2Frag.stageInfo(VK_SHADER_STAGE_FRAGMENT_BIT))
|
||||||
.setVertexInput({m2Binding}, m2Attrs)
|
.setVertexInput({m2Binding}, m2Attrs)
|
||||||
.setTopology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
|
.setTopology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
|
||||||
.setRasterization(VK_POLYGON_MODE_FILL, cullMode)
|
.setRasterization(VK_POLYGON_MODE_FILL, VK_CULL_MODE_NONE)
|
||||||
.setDepthTest(true, depthWrite, VK_COMPARE_OP_LESS_OR_EQUAL)
|
.setDepthTest(true, depthWrite, VK_COMPARE_OP_LESS_OR_EQUAL)
|
||||||
.setColorBlendAttachment(blendState)
|
.setColorBlendAttachment(blendState)
|
||||||
.setMultisample(vkCtx_->getMsaaSamples())
|
.setMultisample(vkCtx_->getMsaaSamples())
|
||||||
|
|
@ -589,26 +588,15 @@ bool M2Renderer::initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout
|
||||||
.build(device, vkCtx_->getPipelineCache());
|
.build(device, vkCtx_->getPipelineCache());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Two-sided pipelines (VK_CULL_MODE_NONE) — for materials with TwoSided flag (0x04)
|
opaquePipeline_ = buildM2Pipeline(PipelineBuilder::blendDisabled(), true,
|
||||||
opaquePipeline_ = buildM2Pipeline(PipelineBuilder::blendDisabled(), true, VK_CULL_MODE_NONE,
|
|
||||||
VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT);
|
VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT);
|
||||||
alphaTestPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), true, VK_CULL_MODE_NONE,
|
alphaTestPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), true,
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
||||||
alphaPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), false, VK_CULL_MODE_NONE,
|
alphaPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), false,
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
||||||
additivePipeline_ = buildM2Pipeline(PipelineBuilder::blendAdditive(), false, VK_CULL_MODE_NONE,
|
additivePipeline_ = buildM2Pipeline(PipelineBuilder::blendAdditive(), false,
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaquePipeline_);
|
||||||
|
|
||||||
// Backface-culled pipelines — default for one-sided materials
|
|
||||||
opaqueCulledPipeline_ = buildM2Pipeline(PipelineBuilder::blendDisabled(), true, VK_CULL_MODE_BACK_BIT,
|
|
||||||
VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT);
|
|
||||||
alphaTestCulledPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), true, VK_CULL_MODE_BACK_BIT,
|
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaqueCulledPipeline_);
|
|
||||||
alphaCulledPipeline_ = buildM2Pipeline(PipelineBuilder::blendAlpha(), false, VK_CULL_MODE_BACK_BIT,
|
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaqueCulledPipeline_);
|
|
||||||
additiveCulledPipeline_ = buildM2Pipeline(PipelineBuilder::blendAdditive(), false, VK_CULL_MODE_BACK_BIT,
|
|
||||||
VK_PIPELINE_CREATE_DERIVATIVE_BIT, opaqueCulledPipeline_);
|
|
||||||
|
|
||||||
// --- Build particle pipelines ---
|
// --- Build particle pipelines ---
|
||||||
if (particleVert.isValid() && particleFrag.isValid()) {
|
if (particleVert.isValid() && particleFrag.isValid()) {
|
||||||
VkVertexInputBindingDescription pBind{};
|
VkVertexInputBindingDescription pBind{};
|
||||||
|
|
@ -873,10 +861,6 @@ void M2Renderer::shutdown() {
|
||||||
destroyPipeline(alphaTestPipeline_);
|
destroyPipeline(alphaTestPipeline_);
|
||||||
destroyPipeline(alphaPipeline_);
|
destroyPipeline(alphaPipeline_);
|
||||||
destroyPipeline(additivePipeline_);
|
destroyPipeline(additivePipeline_);
|
||||||
destroyPipeline(opaqueCulledPipeline_);
|
|
||||||
destroyPipeline(alphaTestCulledPipeline_);
|
|
||||||
destroyPipeline(alphaCulledPipeline_);
|
|
||||||
destroyPipeline(additiveCulledPipeline_);
|
|
||||||
destroyPipeline(particlePipeline_);
|
destroyPipeline(particlePipeline_);
|
||||||
destroyPipeline(particleAdditivePipeline_);
|
destroyPipeline(particleAdditivePipeline_);
|
||||||
destroyPipeline(smokePipeline_);
|
destroyPipeline(smokePipeline_);
|
||||||
|
|
|
||||||
|
|
@ -1147,25 +1147,16 @@ void M2Renderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
|
||||||
}
|
}
|
||||||
if (forceCutout) effectiveBlendMode = 1;
|
if (forceCutout) effectiveBlendMode = 1;
|
||||||
|
|
||||||
const bool twoSided = (batch.materialFlags & 0x04) != 0;
|
|
||||||
VkPipeline desiredPipeline;
|
VkPipeline desiredPipeline;
|
||||||
if (forceCutout) {
|
if (forceCutout) {
|
||||||
// Foliage / ground-detail cards are effectively two-sided
|
|
||||||
desiredPipeline = opaquePipeline_;
|
desiredPipeline = opaquePipeline_;
|
||||||
} else if (twoSided) {
|
} else {
|
||||||
switch (effectiveBlendMode) {
|
switch (effectiveBlendMode) {
|
||||||
case 0: desiredPipeline = opaquePipeline_; break;
|
case 0: desiredPipeline = opaquePipeline_; break;
|
||||||
case 1: desiredPipeline = alphaTestPipeline_; break;
|
case 1: desiredPipeline = alphaTestPipeline_; break;
|
||||||
case 2: desiredPipeline = alphaPipeline_; break;
|
case 2: desiredPipeline = alphaPipeline_; break;
|
||||||
default: desiredPipeline = additivePipeline_; break;
|
default: desiredPipeline = additivePipeline_; break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
switch (effectiveBlendMode) {
|
|
||||||
case 0: desiredPipeline = opaqueCulledPipeline_; break;
|
|
||||||
case 1: desiredPipeline = alphaTestCulledPipeline_; break;
|
|
||||||
case 2: desiredPipeline = alphaCulledPipeline_; break;
|
|
||||||
default: desiredPipeline = additiveCulledPipeline_; break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (desiredPipeline != currentPipeline) {
|
if (desiredPipeline != currentPipeline) {
|
||||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, desiredPipeline);
|
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, desiredPipeline);
|
||||||
|
|
@ -1357,19 +1348,11 @@ void M2Renderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const
|
||||||
else if (effectiveBlendMode == 4 || effectiveBlendMode == 5) effectiveBlendMode = 3;
|
else if (effectiveBlendMode == 4 || effectiveBlendMode == 5) effectiveBlendMode = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool twoSided = (batch.materialFlags & 0x04) != 0;
|
|
||||||
VkPipeline desiredPipeline;
|
VkPipeline desiredPipeline;
|
||||||
if (twoSided) {
|
|
||||||
switch (effectiveBlendMode) {
|
switch (effectiveBlendMode) {
|
||||||
case 2: desiredPipeline = alphaPipeline_; break;
|
case 2: desiredPipeline = alphaPipeline_; break;
|
||||||
default: desiredPipeline = additivePipeline_; break;
|
default: desiredPipeline = additivePipeline_; break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
switch (effectiveBlendMode) {
|
|
||||||
case 2: desiredPipeline = alphaCulledPipeline_; break;
|
|
||||||
default: desiredPipeline = additiveCulledPipeline_; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (desiredPipeline != currentPipeline) {
|
if (desiredPipeline != currentPipeline) {
|
||||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, desiredPipeline);
|
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, desiredPipeline);
|
||||||
currentPipeline = desiredPipeline;
|
currentPipeline = desiredPipeline;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue