Alpha blending problem, can't see some things through it

As you can see in this picture, I can see the lower wood planks but not the higher ones when looking through the grass texture alpha

I’ve tried reversing my z buffer simply by changing my minDepth to 1, maxDepth to 0, changing the compare op to greater_or_equal, and turning the clear value to 0. And it looks slightly better, but I still have the same problem.

Could it be because I am using multidraw indirect with the terrain being in a single buffer? When I update the chunk a grass texture is in, most of the things behind the grass texture become visible, but some chunks that are very close behind are still invisible when looking through the grass alpha. Without updating the chunk it is much worse which explains the grass in the background that isn’t transparent at all.

Here is my code though it is pretty standard:

VkPipelineDepthStencilStateCreateInfo depthStencil{};
        depthStencil.depthTestEnable = VK_TRUE;
        depthStencil.depthWriteEnable = VK_TRUE;
        depthStencil.depthCompareOp = VK_COMPARE_OP_GREATER_OR_EQUAL;// VK_COMPARE_OP_LESS;
        depthStencil.depthBoundsTestEnable = VK_FALSE;
        depthStencil.stencilTestEnable = VK_FALSE;

        VkPipelineColorBlendAttachmentState colorBlendAttachment{};
        colorBlendAttachment.blendEnable = VK_TRUE;
        colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
        colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
        colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD;
        colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
        colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
        colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;

Do I need some depth-independent way of blending or have I overlooked something? Thanks!

If you’re going to have depth testing and alpha blending… yes, you need a depth-independent blending mechanism.

The typical way to do this is to render all opaque objects first, then render potentially transparent one sorted back to front (with depth testing on, but depth writing off). Otherwise, you have to employ an actual order-independent transparency mechanism, which is going to cost performance to some degree.

Before you spend any significant effort on this, try Alpha-to-Coverage. Order independent transparency without explicit sorting or multi-pass. Only requires MSAA. Just enable it and draw.

For much more on this, see:


Bro thank you so much that fixed my problem with a single line of code!

Looks much better now :slight_smile:


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.