Describe the bug
I have two nodes to add scenegraph, one is transparent , another is opaque . I hope the rendering is correct regardless of whether the transparent node is added first or later.
I found if I add opaque first, then add transparent , the rendering is correct.
But if I add transparent first , then add opaque, the rendering is incorrect.
The code looks like this:
first create root sceneGraph:
auto rootScenegraph = vsg::StateGroup::create();
then create transparent subscenegraph:
// translucency subscenegraph
auto transparentScenegraph = vsg::StateGroup::create();
auto transform1 = vsg::MatrixTransform::create();
transparentScenegraph->addChild(transform1);
// colorBlendState with alphablend
auto colorBlendState = vsg::ColorBlendState::create();
colorBlendState->attachments[0].blendEnable = true;
colorBlendState->attachments[0].srcColorBlendFactor = VkBlendFactor::VK_BLEND_FACTOR_CONSTANT_ALPHA;
colorBlendState->attachments[0].dstColorBlendFactor = VkBlendFactor::VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA;
colorBlendState->attachments[0].colorBlendOp = VkBlendOp::VK_BLEND_OP_ADD;
// depthStencilState: no write depth
auto depthStencilState = vsg::DepthStencilState::create();
depthStencilState->depthTestEnable = VK_TRUE;
depthStencilState->depthWriteEnable = VK_FALSE;
vsg::GraphicsPipelineStates pipelineStates{
vsg::VertexInputState::create(vertexBindingsDescriptions, vertexAttributeDescriptions),
vsg::InputAssemblyState::create(),
vsg::RasterizationState::create(),
vsg::MultisampleState::create(),
colorBlendState,
depthStencilState
};
auto pipelineLayout = vsg::PipelineLayout::create(vsg::DescriptorSetLayouts{ descriptorSetLayout }, pushConstantRanges);
auto graphicsPipeline = vsg::GraphicsPipeline::create(pipelineLayout, vsg::ShaderStages{ vertexShader, fragmentShader },
pipelineStates);
auto bindGraphicsPipeline = vsg::BindGraphicsPipeline::create(graphicsPipeline);
transparentScenegraph->add(bindGraphicsPipeline);
transparentScenegraph->add(bindDescriptorSet);
auto drawCommands1 = vsg::Commands::create();
drawCommands1->addChild(vsg::BindVertexBuffers::create(0, vsg::DataList{ vertices, colors }));
drawCommands1->addChild(vsg::BindIndexBuffer::create(indices));
drawCommands1->addChild(vsg::DrawIndexed::create(indicesNum, 1, 0, 0, 0));
transform1->addChild(drawCommands);
then create opacity subscenegraph
// opacity subscenegraph
auto opacityScenegraph = vsg::StateGroup::create();
auto transform2 = vsg::MatrixTransform::create();
opacityScenegraph->addChild(transform2);
...
vsg::GraphicsPipelineStates pipelineStates2{
vsg::VertexInputState::create(vertexBindingsDescriptions, vertexAttributeDescriptions),
vsg::InputAssemblyState::create(),
vsg::RasterizationState::create(),
vsg::MultisampleState::create(),
vsg::ColorBlendState::create(),
vsg::DepthStencilState::create()
};
...
auto drawCommands2 = vsg::Commands::create();
transform2->addChild(drawCommands2);
I add them to root scenegraph.
If I add opacity first, then transparent, the result is correct, code is below:
rootScenegraph->addChild(opacityScenegraph);
rootScenegraph->addChild(transparentScenegraph);
But If I add transparent first, then opacity , the result is incorrect, code is below:
rootScenegraph->addChild(transparentScenegraph);
rootScenegraph->addChild(opacityScenegraph);
Expected behavior
I don't think I need care about which one add first. Am I using it wrong?
Screenshots
there are two planes, the position of opaque plane is below transparent plane.
opaque add first ,the rendering is correct:

transparent add first, the rendering is incorrect:

Describe the bug
I have two nodes to add scenegraph, one is transparent , another is opaque . I hope the rendering is correct regardless of whether the transparent node is added first or later.
I found if I add opaque first, then add transparent , the rendering is correct.
But if I add transparent first , then add opaque, the rendering is incorrect.
The code looks like this:
first create root sceneGraph:
then create transparent subscenegraph:
then create opacity subscenegraph
I add them to root scenegraph.
If I add opacity first, then transparent, the result is correct, code is below:
But If I add transparent first, then opacity , the result is incorrect, code is below:
Expected behavior
I don't think I need care about which one add first. Am I using it wrong?
Screenshots

there are two planes, the position of opaque plane is below transparent plane.
opaque add first ,the rendering is correct:
transparent add first, the rendering is incorrect:
