0

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.

Leon
  • 554
  • 4
  • 18
  • A render pass doesn't have a sample count; the *attachments* to a render pass do. And the images you eventually use when you instantiate that render pass *must match* the sample count you used for the attachments those images get used with. – Nicol Bolas Apr 16 '20 at 14:53
  • If you could give a bit more details about what you want to achieve, we maybe could give some advice. Do you want to rasterize into multi-sample attachments and resolve the multi-sampled result afterwards into a `VK_SAMPLE_COUNT_1_BIT` attachment, or is it something else you are trying to do? How do you want to use the texture you are describing with "but my texture would still be VK_SAMPLE_COUNT_1_BIT"? – j00hi Apr 17 '20 at 09:52
  • I apply a texture created offscreen on a plan. The texture is half transparent. I want to keep the transparency once apply on the plan. It doesn't really matter if the texture is multi-sample. – Leon Apr 17 '20 at 13:58
  • Nicol > I'll try with a resolve attachment tomorrow. I lost more time turning around the blend settings than testing the more obvious solution. – Leon Apr 17 '20 at 22:16

0 Answers0