Material QML Type

不可创建的材料抽象基础。更多

属性

详细说明

Material 提供了一种指定entity 渲染的方法。任何方面都可以定义自己的 Material 子类型,这样 Material 就可以用来描述视觉元素;例如,声音在元素上的反射方式、表面的温度等。

材料本身并没有任何作用。只有在引用 "效果 "节点时,"材质 "才会变得有用。

在实践中,经常会出现一个效果被多个材质组件引用的情况。这样就可以只创建一次效果、技术、通道和着色器,同时还可以通过添加参数实例来指定材质。

在材质上定义的参数会覆盖在效果、技术和RenderPass 中定义的参数(同名),但会被RenderPassFilterTechniqueFilter 中的参数覆盖。

Effect {
    id: effect

    techniques: [
        Technique {
            id: gl3Technique
            graphicsApiFilter {
                api: GraphicsApiFilter.OpenGL
                profile: GraphicsApiFilter.CoreProfile
                majorVersion: 3
                minorVersion: 1
            }
            renderPasses: [
                RenderPass {
                    id: gl3Pass
                    shaderProgram: ShaderProgram {
                        ...
                    }
                }
            ]
        }
    ]
}

Material {
    id: material1
    parameters: [
        Parameter { name: "color"; value: "green" }
    ]
}

Material {
    id: material2
    parameters: [
        Parameter { name: "color"; value: "white" }
    ]
}

另请参阅 Effect,Technique, 和Parameter

属性文档

effect : Effect

指定与材质一起使用的效果。


parameters : list<Parameter>

保存材质使用的参数列表。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.