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

Qt3DExtra Materials do not define QFilterKeys in their RenderPass

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.5
    • Qt3D
    • None

    Description

      I'm trying to define multiple Materials for a single object (a simple cube) and use each Material in a separate RenderView of the Framegraph.

      The idea is to use a Qt3DExtras::QPhongLighting in one viewport and a custom material with a very simple shader (simple custom material example of qt3d) as the material in the other viewport. So I ultimately want to be able to select which material component to use in which RenderView, without having to create multiple Entities of the same object (only one cube geometry with multiple materials).

      I tried various different approaches now and can't seem to get QRenderPassFilter to work as expected with the default Qt3DExtra Materials.

      Qt3DExtra Materials do not define QFilterKeys in their RenderPass

      While a Qt3DExtra::QPhongLighting Material has a QFilterKey as child node, the RenderPasses have no FilterKeys assigned at all:

      Qt3DExtras::QPhongMaterial *cubeMaterial = new Qt3DExtras::QPhongMaterial(cube);
      cubeMaterial->dumpObjectTree();
      

      Output:

      Qt3DExtras::QPhongMaterial::
          Qt3DRender::QFilterKey::  
          Qt3DRender::QEffect::  
              Qt3DRender::QTechnique::  
                  Qt3DRender::QRenderPass::  
                      Qt3DRender::QShaderProgram::  
              Qt3DRender::QTechnique::  
                  Qt3DRender::QRenderPass::  
                      Qt3DRender::QShaderProgram::  
              Qt3DRender::QTechnique::  
                  Qt3DRender::QRenderPass::  
              Qt3DRender::QParameter::  
              Qt3DRender::QParameter::  
              Qt3DRender::QParameter::  
              Qt3DRender::QParameter::
      

       

          QVector<Qt3DCore::QNode*> children;
          children.append(sceneContent);
          while(children.size())
          {
              Qt3DCore::QNode* node = children.first();
              children.pop_front();
              for(Qt3DCore::QNode *childNode : node->childNodes())
              {
                  children.append(childNode);
              }
      
              if(qobject_cast<Qt3DRender::QRenderPass*>(node))
              {
                  std::cout << qobject_cast<Qt3DRender::QRenderPass*>(node)->filterKeys().size() << std::endl;
              }
          }
      

       Output:

      0
      0
      0
      

      This makes it impossible to only select solely the default Qt3DExtra Materials in the framegraph, as there are no FilterKeys assigned. The obvious fix is to add the QFilterKeys by hand:

      children.append(sceneContent);
          while(children.size())
          {
              Qt3DCore::QNode* node = children.first();
              children.pop_front();
              for(Qt3DCore::QNode *childNode : node->childNodes())
              {
                  children.append(childNode);
              }
      
              if(qobject_cast<Qt3DRender::QRenderPass*>(node))
              {
                  if(qobject_cast<Qt3DRender::QRenderPass*>(node)->filterKeys().size() == 0)
                  {
                      qobject_cast<Qt3DRender::QRenderPass*>(node)->addFilterKey(passCriteria[0]);
                  }
              }
          }
      

      With passCriteria[0] being the QFilterKey child of the QPhongMaterial, which can be selected in the same manner by traversing the tree and searching for QFilterKeys. Having the QFilterKey assigned to the RenderPasses should be default behavior and way better documented, to enable users to use the predefined Qt3DExtra materials in their framegraph's QRenderPassFilter.

      Attachments

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

        Activity

          People

            seanharmer Sean Harmer
            ufedv Philipp Schmidt
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes