I want to render a custom mesh (LAB.obj) with a certain transparency in a Qt3D scene. I use QDiffuseSpecularMaterial
with diffuse color set to Qt.rgba(1,0.6,0.42,0.9)
- alpha value is 0.9. I get strange horizontal stripes throughout my model when rendered and parts of the object which should be in the back erroneously appear in the front. See the following image:
What am I doing wrong?
Here is the code broken down to the important parts:
Item {
Scene3D {
id: scene
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,40)
upVector: Qt.vector3d( 0,1,0 )
viewCenter: Qt.vector3d(0,0,0)
}
OrbitCameraController {
camera: camera
linearSpeed: -200
lookSpeed: -180
}
components: [
RenderSettings {
ForwardRenderer {
camera: camera
clearColor: "transparent"
}
},
InputSettings {}
]
Entity {
id: customEntity
components: [
DiffuseSpecularMaterial {
diffuse: Qt.rgba(1,0.6,0.42,0.9)
alphaBlending:true
},
Mesh {
id: customMesh
source: "qrc:LAB"
}
]
}
}
}
}