Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.2, 5.15.0
-
None
-
Compiler: MSVC2017, MSVC2019,
Renderer: OpenGL 4.4, OpenGL 4.6, ANGLE(Direct3D 11)
Windows 10 x64
Description
When displaying a textured plane with alpha channel, objects that are behind are obscured more than expected. This only seems to be the case when compositingMode of Scene3D is set to FBO. This issue was also not observed when using Qt3DWindow instead of Scene3D.
Consider the image:
https://imgur.com/jJdoZiT
When compositingMode is set to Underlay, results are as expected:
https://imgur.com/S3KYrwC
The fully and partially transparent areas are rendered correctly.
When the compositingMode is set to Overlay, we get this:
https://imgur.com/PThbkbL
Semitransparent areas let some of the background objects through but fully transparent area appear to take the color of the QQuickView background color (and not the clear color of Scene3D)
Method used to render the image:
void drawImage(const QImage image, const QVector3D middlePoint, const float width, const float height) const { Qt3DCore::QEntity *planeEntity = new Qt3DCore::QEntity(mRootEntity); Qt3DExtras::QPlaneMesh *planeMesh = new Qt3DExtras::QPlaneMesh(planeEntity); planeMesh->setWidth(width); planeMesh->setHeight(height); Qt3DExtras::QTextureMaterial *planeMaterial = new Qt3DExtras::QTextureMaterial(planeEntity); planeMaterial->setAlphaBlendingEnabled(true); Qt3DRender::QTexture2D *planeTexture = new Qt3DRender::QTexture2D(planeMaterial); SemiopaqueTextureImage *planeTextureImage = new SemiopaqueTextureImage(image, planeTexture); planeTexture->addTextureImage(planeTextureImage); planeMaterial->setTexture(planeTexture); Qt3DCore::QTransform *planeTransform = new Qt3DCore::QTransform(planeEntity); planeTransform->setRotationX(90); planeTransform->setTranslation(middlePoint); planeEntity->addComponent(planeMesh); planeEntity->addComponent(planeMaterial); planeEntity->addComponent(planeTransform); }
SemiopaqueTextureImage inherits from QPaintedTextureImage that paints a QImage e.g.:
painter->setCompositionMode(QPainter::CompositionMode_Source); painter->drawImage(0, 0, imageToPaint);
I've read per https://doc.qt.io/qt-5/qml-qtquick-scene3d-scene3d.html that for Scene3D "you may need to modify those materials with custom blend arguments in order for them to be rendered correctly" but I could not find a way to do so for QTextureMaterial.
(JIRA does not let me attach images, hence the links - apologies)