Custom Material only uses two properties to control alpha behaviour but for correct lighting we need 4 -> at least to achieve the same behaviour as it is done in principled material.
PrincipledMaterial uses (qssglayerrenderdata.cpp):
case QSSGRenderDefaultMaterial::MaterialBlendMode::Screen: targetBlend->srcColor = QRhiGraphicsPipeline::SrcAlpha; targetBlend->dstColor = QRhiGraphicsPipeline::One; targetBlend->srcAlpha = QRhiGraphicsPipeline::One; targetBlend->dstAlpha = QRhiGraphicsPipeline::One; break; case QSSGRenderDefaultMaterial::MaterialBlendMode::Multiply: targetBlend->srcColor = QRhiGraphicsPipeline::DstColor; targetBlend->dstColor = QRhiGraphicsPipeline::Zero; targetBlend->srcAlpha = QRhiGraphicsPipeline::One; targetBlend->dstAlpha = QRhiGraphicsPipeline::One; break; default: // Use SourceOver for everything else targetBlend->srcColor = QRhiGraphicsPipeline::SrcAlpha; targetBlend->dstColor = QRhiGraphicsPipeline::OneMinusSrcAlpha; targetBlend->srcAlpha = QRhiGraphicsPipeline::One; targetBlend->dstAlpha = QRhiGraphicsPipeline::OneMinusSrcAlpha; break; }
But with Custom Material the two properties are assigned both to src and dst:
qssgrhicustommaterialsystem.cpp:
blend.srcColor = material.m_srcBlend; blend.srcAlpha = material.m_srcBlend; blend.dstColor = material.m_dstBlend; blend.dstAlpha = material.m_dstBlend;
For Gerrit Dashboard: QTBUG-118404 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
513832,3 | Add separate controls for RGB and Alpha blending in custom materials | dev | qt/qtquick3d | Status: MERGED | +2 | 0 |