ShaderImage QML Type
提供对着色器程序的图像访问。更多
Import Statement: | import Qt3D.Render 2.9 |
In C++: | QShaderImage |
Status: | Deprecated |
属性
详细说明
要在着色器中读写纹理内容,需要将纹理作为 ShaderImage 暴露。纹理可以由多个 mip 层、层和面组成。此外,声明 ShaderImage 还可以指定我们要访问纹理内容的哪个层、图层或面。
ShaderImage 必须指定为参数值,并引用一个有效的 Qt3D.Render.AbstractTexture 才能正常工作。
如果引用的纹理是一维数组、二维数组、三维、立方体贴图、立方体贴图数组或二维多采样数组纹理,则可以绑定整个纹理层或纹理层的单层或单面。这可以通过layered 属性进行控制。
ShaderImage 仅支持 OpenGL 4,部分支持 OpenGL ES 3.1 和 3.2。
OpenGL 4 支持以下图像类型:
GLSL 类型 | OpenGL 类型枚举 | 纹理类型 |
---|---|---|
图像 1D | GL_IMAGE_1D | Texture1D |
图像2D | GL_IMAGE_2D | Texture2D |
图像 3D | GL_IMAGE_3D | Texture3D |
image2DRect | gl_image_2d_rect | TextureRectangle |
图像立方体 | 图像立方体 | TextureCubeMap |
图像缓冲区 | gl_image_buffer | TextureBuffer |
image1DArray | gl_image_1d_array | Texture1DArray |
图像 2DArray | gl_image_2d_array | Texture2DArray |
图像立方数组 | gl_image_cube_map_array | TextureCubeMapArray |
图像2DMS | gl_image_2d_multisample | Texture2DMultisample |
图像 2DMSArray | gl_image_2d_multisample_array | Texture2DMultisampleArray |
iimage1D | gl_int_image_1d | Texture1D |
iimage2D | gl_int_image_2d | Texture2D |
iimage3D | gl_int_image_3d | Texture3D |
iimage2DRect | gl_int_image_2d_rect | TextureRectangle |
iimageCube | gl_int_image_cube | TextureCubeMap |
iimageBuffer | gl_int_image_buffer | TextureBuffer |
iimage1DArray | gl_int_image_1d_array | Texture1DArray |
iimage2DArray | gl_int_image_2d_array | Texture2DArray |
iimageCubeArray | gl_int_image_cube_map_array | TextureCubeMapArray |
iimage2DMS | gl_int_image_2d_multisample | Texture2DMultisample |
iimage2DMSArray | gl_int_image_2d_multisample_array | Texture2DMultisampleArray |
uimage1D | gl_unsigned_int_image_1d | Texture1D |
uimage2D | gl_unsigned_int_image_2d | Texture2D |
uimage3D | gl_unsigned_int_image_3d | Texture3D |
uimage2DRect | gl_unsigned_int_image_2d_rect | TextureRectangle |
uimageCube | gl_unsigned_int_image_cube | TextureCubeMap |
uimageBuffer | gl_unsigned_int_image_buffer | TextureBuffer |
uimage1DArray | gl_unsigned_int_image_1d_array | Texture1DArray |
uimage2DArray | gl_unsigned_int_image_2d_array | Texture2DArray |
uimageCubeArray | gl_unsigned_int_image_cube_map_array | TextureCubeMapArray |
uimage2DMS | gl_unsigned_int_image_2d_multisample | Texture2DMultisample |
uimage2DMSArray | gl_unsigned_int_image_2d_multisample_array | Texture2DMultisampleArray |
OpenGL ES 3.1 支持以下图像类型:
GLSL 类型 | OpenGL 类型枚举 | 纹理类型 |
---|---|---|
图像 2D | GL_IMAGE_2D | Texture2D |
图像 3D | GL_IMAGE_3D | Texture3D |
图像立方体 | 图像立方体 | TextureCubeMap |
image2DArray | gl_image_2d_array | Texture2DArray |
iimage2D | gl_int_image_2d | Texture2D |
iimage3D | gl_int_image_3d | Texture3D |
图像立方体 | gl_int_image_cube | TextureCubeMap |
iimage2DArray | gl_int_image_2d_array | Texture2DArray |
uimage2D | gl_unsigned_int_image_2d | Texture2D |
uimage3D | gl_unsigned_int_image_3d | Texture3D |
uimageCube | gl_unsigned_int_image_cube | TextureCubeMap |
uimage2DArray | gl_unsigned_int_image_2d_array | Texture2DArray |
OpenGL ES 3.2 支持所有 OpenGL ES 3.1 图像类型以及以下类型:
GLSL 类型 | OpenGL 类型枚举 | 纹理类型 |
---|---|---|
图像缓冲区 | gl_image_buffer | TextureBuffer |
图像立方数组 | 图像立方图数组 | TextureCubeMapArray |
iimageBuffer | gl_image_buffer | TextureBuffer |
图像立方数组 | gl_int_image_cube_map_array | TextureCubeMapArray |
uimageBuffer | gl_unsigned_int_image_buffer | TextureBuffer |
uimageCubeArray | gl_unsigned_int_image_cube_map_array | TextureCubeMapArray |
预期用途如下
import Qt3D.Render 2.14 Entity { ... Texture2D { id: tex2D ... } Material { parameters: Parameter { name: "imageUniformName" value: ShaderImage { texture: tex2D } } ... } ... }
属性文档
access : enumeration |
指定允许着色器实例访问图像的类型。如果着色器试图写入或读取不兼容访问的图像,其行为将是未定义的。
常量 | 说明 |
---|---|
ShaderImage.ReadOnly | 只读访问。 |
ShaderImage.WriteOnly | 只写访问 |
ShaderImage.ReadWrite | 读写访问。 |
默认值为ShaderImage.ReadWrite。
format : enumeration |
指定图像格式,这对于在ShaderImage 中存储来自着色器的值非常重要。
格式不一定要与引用纹理的格式相同。但必须兼容(大小匹配,但不一定是类类型匹配)。例如,格式为 R32F(大小为 32 位,类别为 1x32)的纹理可以与格式为 RGBA8I(大小为 32 位,类别为 4x8)的图像一起使用。OpenGL 规范的表 8.27 显示了所有支持的图像格式的大小和类别。
默认情况下,Qt3D 会尝试设置图像格式,使其与引用纹理的格式相匹配。
默认值是ShaderImage.Automatic(自动)。
layer : int |
保持引用纹理中的哪个图层应被用于ShaderImage 。如果layered 设置为 true 或引用纹理的类型与图层不兼容,该属性将不起作用。
注: 当引用的纹理类型为立方体贴图或立方体贴图数组,且ĺayered 设置为 false 时,面和层将按以下方式获取:
cubeMapLayer = layer / 6 cubeMapFace = layer - (cubeMapLayer * 6)
默认值为 0。
layered : bool |
*
如果设置为 true,如果引用的纹理是一维数组、二维数组、三维、立方体贴图、立方体贴图数组或二维多采样数组纹理,则将绑定整个层的所有层。如果设置为 false,则只绑定layer 属性指定的单个图层。
默认值为false
。
mipLevel : int |
mipLevel(mipLevel 属性):表示ShaderImage 应使用引用纹理中的哪个 mipLevel。
默认值为 0。
© 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.