gist
so you can look at the main application code. Let me know if you need to see more.
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., 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来改变访问掩码。