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

Erroneously rendering of transparent mesh with background color in QQuickview

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.1
    • Qt3D
    • None
    • Qt Creator
    • Windows

    Description

      Rendering of a very transparent Mesh (DiffuseSpecularMaterial with alpha channel of diffuse color value 0.1 and alphaBlending set to true) in a QQuickView results in a slightly transparent black (color of qquickview) mesh instead of a very transparent mesh.

       

      Example code

      C++:

      // int main(int argc, char *argv[])
      {
      
          QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
          QApplication app(argc, argv);
          QMainWindow mainWindow;
      
          QWidget* viewersContainerWidget = new QWidget();
          QGridLayout* m_viewersLayout = new QGridLayout(viewersContainerWidget);
          m_viewersLayout->setContentsMargins(0, 0, 0, 0);
      
          QQuickView *quickView = new QQuickView();
          quickView->setSource(QUrl("qrc:/main.qml"));
          quickView->setResizeMode(QQuickView::SizeRootObjectToView);
          quickView->setColor("transparent");
          QWidget *container = QWidget::createWindowContainer(quickView);
          container->setMinimumSize(800, 800);
          m_viewersLayout->addWidget(container, 0, 1);
          mainWindow.setCentralWidget(viewersContainerWidget);
      
          mainWindow.resize(800, 600);
          mainWindow.show();
      
          return app.exec();
      }
      

      QML:

      Item {
          id: root3DViewer
          Scene3D {
              id: scene3DRoot
              anchors.fill: parent
              aspects: ["input", "logic"]
      
              Entity {
                  id: sceneRoot
      
                  Camera {
                      id: camera
                      projectionType: CameraLens.PerspectiveProjection
                      nearPlane : 0.01
                      farPlane : 1000.0
                      fieldOfView: 45
                      position: Qt.vector3d(0,0,-20)
                      viewCenter: Qt.vector3d(0,0,2.5)
                  }
      
                  OrbitCameraController {
                      camera: camera
                  }
      
      
                  components: [
                      RenderSettings {
                           ForwardRenderer {
                              camera: camera
                              clearColor: "black"
                          }
                      },
                      InputSettings {}
                  ]
      
                  Entity {
                      DirectionalLight {
                          id:directionalLight
                          worldDirection: camera.viewVector
                      }
                      components: [directionalLight]
                  }
      
      
      
                  Entity {
                      id: sphereEntity
                      DiffuseSpecularMaterial {
                          id: sphereMaterial
                          diffuse: Qt.rgba(1,0,0,0.9)
                          alphaBlending: true
                      }
                      Transform {
                          id: sphereTransform
                          translation: Qt.vector3d(0,0,0)
                      }
      
                      SphereMesh {
                          id: sphereMesh
                          radius: 1
                      }
                  components: [sphereTransform, sphereMaterial,sphereMesh]
                  }
                  Entity {
                      id: cylinderEntity
                      DiffuseSpecularMaterial {
                          id: cylinderMaterial
                          diffuse: Qt.rgba(0,0,1,0.1)
                          alphaBlending: true
                      }
                      Transform {
                          id: cylinderTransform
                          translation: Qt.vector3d(0,0,5)
                      }
      
                      CylinderMesh {
                          id: cylinderMesh
                          length: 4
                          radius: 1
                      }
                  components: [cylinderTransform, cylinderMaterial,cylinderMesh]
                  }
      
              }
          }
      }
      

      Using a Qt3DQuickWindow instead works fine

      
          QGuiApplication app(argc, argv);
      
          Qt3DExtras::Quick::Qt3DQuickWindow view;
          view.resize(1600, 800);
          view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
          view.setSource(QUrl("qrc:/main.qml"));
          view.show();
      
          return app.exec();
      

      Attachments

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

        Activity

          People

            seanharmer Sean Harmer
            91daniel.schneider Daniel Schneider
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes