首页 > 解决方案 > qt 3d Qml 透明 Scene2D 纹理

问题描述

如何在没有此默认灰色背景的情况下渲染网格纹理?我的意思是,使用 Scene2D 组件来生成带有 alpha 的纹理。现在看起来我的红色矩形下方有 PhonMaterial。

Entity {
id: root

components: [cubeTransform, cubeMaterial, cubeMesh]
PlaneMesh {
    id: cubeMesh
    width: 10
    height: 10
}
Transform {
    id: cubeTransform
    translation: Qt.vector3d(0, 4, 0)
    scale3D: Qt.vector3d(1, 1, 1)
}
TextureMaterial   {
    id: cubeMaterial
    texture: textureId
}
Scene2D {
    id: qmlTexture
    output: RenderTargetOutput {
        attachmentPoint: RenderTargetOutput.Color0
        texture: Texture2D {
            id: textureId

            width: 100
            height: 1024
            format: Texture.RGBA8_UNorm
            generateMipMaps: true
            magnificationFilter: Texture.Linear
            minificationFilter: Texture.LinearMipMapLinear
            wrapMode {
                x: WrapMode.ClampToEdge
                y: WrapMode.ClampToEdge
            }
        }
    }
    Rectangle {
        x: 50
        width: 50
        height: textureId.height
        color: "red"
    }
}
 }

现在,一半的网格是红色的(应该如此),但第二个是白色的,而不是透明的。

在此处输入图像描述

标签: qtopenglqmlqt3d

解决方案


推荐阅读