Qt3d正确渲染透明网格

时间:2019-03-12 10:56:02

标签: qt rendering depth-buffer qt3d

我想在Qt3D场景中渲染具有一定透明度的自定义网格物体(LAB.obj)。我将QDiffuseSpecularMaterial的漫反射色设置为Qt.rgba(1,0.6,0.42,0.9)-alpha值为0.9。渲染时,在整个模型中出现奇怪的水平条纹,而应该在后面的对象部分错误地出现在前面。参见下图:

enter image description here

我在做什么错了?

以下是细分为重要部分的代码:

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"
                }
            ]
        }

    }



}

}

0 个答案:

没有答案