texture with alpha component rendered offscreen: dots pattern in a multisample renderPass

277 Views Asked by At

I create an offscreen texture with alpha component, samples in the offscreen renderPass is VK_SAMPLE_COUNT_1_BIT. When I use this texture in a VK_SAMPLE_COUNT_4_BIT renderPass, I get black dots pattern where there is an alpha component. I understand why, but I don't know how to solve this problem.

I thought I could use an offscreen renderpass with VK_SAMPLE_COUNT_4_BIT with another VK_SAMPLE_COUNT_1_BIT attachment to resolve into, but my texture would still be VK_SAMPLE_COUNT_1_BIT. So I'm not sure it will solve the black dots issue, and I prefer to seek advice before I get into big changes.

-------- edit 1 --------

The dots appear when I use these VkPipelineMultisampleStateCreateInfo setting:

.alphaToCoverageEnable = VK_TRUE;
.alphaToOneEnable      = VK_TRUE;

If these two setting are set to VK_FALSE, I've got transparent texture but without any gradient, it's transparent or opaque.

Here are my VkPipelineColorBlendAttachmentState setting for both offscreen and texturing renderPass:

.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
.colorBlendOp = VK_BLEND_OP_ADD;
.alphaBlendOp = VK_BLEND_OP_ADD;

When I look at the offscreen texture with a green "clear color", I can see the gradient of transparency, so I suppose the offscreen renderPass is correctly set.

-------- edit 2 --------

I modified the offscreen renderPass in order to use the same sample count as in the onscreen, or final, renderPass, by hadding a resolve attachment with VK_SAMPLE_COUNT_1_BIT.

I still have dots if I set .alphaToCoverageEnable and .alphaToOneEnable to VK_TRUE. When set to false, the full image is semi-transparent, even the opaques parts.

0

There are 0 best solutions below