本页内容

Parameter QML Type

用于存储名称和值对。这对应于着色器统一变量。更多...

Import Statement: import Qt3D.Render 2.12
In C++: QParameter
Status: Deprecated

此类型已弃用。我们强烈建议在新代码中不要使用它。

属性

详细说明

参数可被RenderPass 、Technique、Effect、Material、TechniqueFilter 以及RenderPassFilter 引用。在运行时,根据渲染的特定步骤所选定的着色器,如果该着色器中包含一个名称与该参数匹配的uniform,则参数中的值将被转换并上传。

Parameter {
    name: "diffuseColor"
    value: "blue"
}

// Works with the following GLSL uniform shader declarations
// uniform vec4 diffuseColor;
// uniform vec3 diffuseColor;
// uniform vec2 diffuseColor;
// uniform float diffuseColor;

注意:必须谨慎 确保参数封装的值确实能够转换为真实uniform所期望的类型。若实际着色器uniform的类型为float,却传入以int形式存储的值,可能会导致未定义的行为。

注意:当 目标统一变量是一个数组时 ,名称应为该统一变量的名称后附加 [0]。

注意: 无法禁用“参数 ”节点。

Parameter {
    name: "diffuseValues[0]"
    value: [0.0, 1.0. 2.0, 3.0, 4.0, 883.0, 1340.0, 1584.0]
}

// Matching GLSL shader uniform  declaration
// uniform float diffuseValues[8];

在纹理支持方面,应将“参数”的值设置为与着色器uniform采样器类型相匹配的适当texture 子类。

Parameter {
    name: "diffuseTexture"
    value: Texture2D { ... }
}

// Works with the following GLSL uniform shader declaration
// uniform sampler2D diffuseTexture

另请参阅 Qt3DRender::QAbstractTexture 。

属性文档

name : string

指定参数的名称

value : QVariant

指定该参数的值

© 2026 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.