Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-118404

Unable to replicate PrincipledMaterial Behaviour with CustomMaterial (no way to specify separate blend factors)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.7.0 FF
    • 6.5.1
    • Quick: 3D
    • None
    • Windows
    • 1633d6c1c (dev)

      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;

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.graphics.and.multimedia Qt Graphics Team
            olf Olaf Arkanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes