VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT) but let the subpasses take care of it

问题描述 投票:0回答:1
Since Vulkan code is commonly very long, I've created a

gist

enter image description here

so you can look at the main application code. Let me know if you need to see more.

enter image description here

enter image description here

  • I loaded a model using tinyobjloader in a Vulkan application. The color of each vertex simply equals its 3d position. Using RenderDoc I verified that the depth buffer is working correctly: But the ...
  • Color blending is order dependent operation, and so tricky when used with depth buffering.

Your code is:Primitives (triangles) are processed in primitime order. Here notably, the triangle that is first in your index buffer will be processed first.Now, as depth testing works is that a fragment proceeds if it passes the depth test. That means one fragment could suceed. Then other fragment with even better depth value could overwrite it.

This affects your Dst blend value. In your case it will either be the clear color, or the previous fragment color, depending on whichever happens first, per the primitive order.
graphics 3d vulkan
1个回答
1
投票

, then it results in

, which is probably non-sense, but not noticable. But if

vk::PipelineColorBlendAttachmentState colorBlendAttachment(true,
vk::BlendFactor::eSrcColor, vk::BlendFactor::eOneMinusSrcColor,
vk::BlendOp::eAdd,
vk::BlendFactor::eOne, vk::BlendFactor::eZero,
vk::BlendOp::eAdd,

is something, then your output becomes some bright artifact color with more of a Dst's tint.

我在 Vulkan 应用程序中使用 tinyobjloader 加载了一个模型。每个顶点的颜色简单地等于它的三维位置。使用RenderDoc我验证了深度缓冲区工作正常。

但是颜色输出显示了一些奇怪的伪影 你会看到被遮挡的顶点 srcColor * srcColor + dstColor * (1-srcColor)这是使用phong照明时的伪影效果 0面部方向和剔除是正确的2*srcColor我试过SRGB和SFLOAT两种图像格式,结果都一样。dstColor我没有明确地过渡布局(因此没有使用VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT来改变访问掩码。

© www.soinside.com 2019 - 2024. All rights reserved.