Qt3D - wrong material blending with clearColor
Unsolved
Game Development
-
Hi,
I have the following application:
- main.cpp with a
QGuiApplication
and aQQmlApplicationEngine
that loads the main.qml - main.qml with a
Window{w:500, h:500, color:"limegreen"}
as root component - A
Scene3D{w:400, h:500}
centered in the Window
The scene3d has the following tree in pseudocode
- RootEntity
- Camera
- RenderSettings
- ForwardRenderer
- DiffuseSpecularMaterial (id:planeMaterial; color:0.745, 0.745, 0.745, 1)
- PlaneMesh: (id:planeMesh; width:7; height:7)
- Transform: (id:planeTransform; translation:-2.5, 2.5, -14)
- Entity: (id: planeEntity) // PLANE
- DiffuseSpecularMaterial (id:sphere1Material; color:1, 0, 0, 0.2; alphaBlending:true)
- SphereMesh: (id:sphere1Mesh; radius:2.5)
- Transform: (id:sphere1Transform; translation:-2.5, 2.5, -14)
- Entity: (id: sphere1Entity) // SPHERE TOP-LEFT
- PhongAlphaMaterial (id:sphere2Material; color:1, 0, 0; alpha:0.2; sourceAlphaArg:Zero; destinationAlphaArg:One)
- SphereMesh: (id:sphere2Mesh; radius:2.5)
- Transform: (id:sphere2Transform; translation:2.5, -2.5, -14)
- Entity: (id: sphere2Entity) // SPHERE BOTTOM-RIGHT
Important info:
- The Sphere 1 is composed with the DiffuseSpecularMaterial which aparently supports alpha values and alpha blending, but the resulting color/alha are wrong. Looks like it is blending just with the Window color (limegreen) instead of the Plane (white)
- In order to fix this, I followed the recomendation of using PhongAlphaMaterial(deprecated btw) and set the sourceAlphaArg: BlendEquationArguments.Zero and destinationAlphaArg: BlendEquationArguments.One. This is done in Sphere 2, that is working fine:
The problem now is when I set the clear color transparent
clearColor: Qt.rgba(1, 1, 1, 0)
. As none of the materials is working fine. This is the result:
My machine has Ubuntu 20.04 and Qt5.14.2
The objective is to have a scene with a transparent ClearColor in order to see what is "behind" the Scene3D in the QtQuickWindow, but also have opaque/non-opaque objects in my Scene3D... so.... I'm a bit confused, I dont know if this is a expected behaviour of if i'm doing something wrong...
I would appreciate any help or hint about whats happening
(If necessary I can share the code to reproduce this)
Thanks.
- main.cpp with a