ShaderImage QML Type

Provides Image access to shader programs. More...

Import Statement: import Qt3D.Render 2.8
In C++: QShaderImage
Status: Deprecated

Properties

Detailed Description

To make the content of textures available for read and write operations in a shader, they need to exposed as ShaderImage. Textures can be composed of several mip levels, layers and faces. Additionally declaring a ShaderImage allows specifying which level, layer or face of the texture content we want to access.

ShaderImage has to be assigned as a Parameter's value and reference a valid Qt3D.Render.AbstractTexture to work properly.

If the referenced texture is a one-dimensional array, two-dimensional array, three-dimensional, cube map, cube map array, or two-dimensional multisample array texture, it is possible to bind either the entire texture level or a single layer or face of the texture level. This can be controlled with the layered property.

Support for ShaderImage is only supported with OpenGL 4 and partially with OpenGL ES 3.1 and 3.2.

OpenGL 4 supports the following image types:

GLSL TypeOpenGL Type EnumTexture Type
image1DGL_IMAGE_1DTexture1D
image2DGL_IMAGE_2DTexture2D
image3DGL_IMAGE_3DTexture3D
image2DRectGL_IMAGE_2D_RECTTextureRectangle
imageCubeGL_IMAGE_CUBETextureCubeMap
imageBufferGL_IMAGE_BUFFERTextureBuffer
image1DArrayGL_IMAGE_1D_ARRAYTexture1DArray
image2DArrayGL_IMAGE_2D_ARRAYTexture2DArray
imageCubeArrayGL_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray
image2DMSGL_IMAGE_2D_MULTISAMPLETexture2DMultisample
image2DMSArrayGL_IMAGE_2D_MULTISAMPLE_ARRAYTexture2DMultisampleArray
iimage1DGL_INT_IMAGE_1DTexture1D
iimage2DGL_INT_IMAGE_2DTexture2D
iimage3DGL_INT_IMAGE_3DTexture3D
iimage2DRectGL_INT_IMAGE_2D_RECTTextureRectangle
iimageCubeGL_INT_IMAGE_CUBETextureCubeMap
iimageBufferGL_INT_IMAGE_BUFFERTextureBuffer
iimage1DArrayGL_INT_IMAGE_1D_ARRAYTexture1DArray
iimage2DArrayGL_INT_IMAGE_2D_ARRAYTexture2DArray
iimageCubeArrayGL_INT_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray
iimage2DMSGL_INT_IMAGE_2D_MULTISAMPLETexture2DMultisample
iimage2DMSArrayGL_INT_IMAGE_2D_MULTISAMPLE_ARRAYTexture2DMultisampleArray
uimage1DGL_UNSIGNED_INT_IMAGE_1DTexture1D
uimage2DGL_UNSIGNED_INT_IMAGE_2DTexture2D
uimage3DGL_UNSIGNED_INT_IMAGE_3DTexture3D
uimage2DRectGL_UNSIGNED_INT_IMAGE_2D_RECTTextureRectangle
uimageCubeGL_UNSIGNED_INT_IMAGE_CUBETextureCubeMap
uimageBufferGL_UNSIGNED_INT_IMAGE_BUFFERTextureBuffer
uimage1DArrayGL_UNSIGNED_INT_IMAGE_1D_ARRAYTexture1DArray
uimage2DArrayGL_UNSIGNED_INT_IMAGE_2D_ARRAYTexture2DArray
uimageCubeArrayGL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray
uimage2DMSGL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLETexture2DMultisample
uimage2DMSArrayGL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAYTexture2DMultisampleArray

OpenGL ES 3.1 supports the following image types:

GLSL TypeOpenGL Type EnumTexture Type
image2DGL_IMAGE_2DTexture2D
image3DGL_IMAGE_3DTexture3D
imageCubeGL_IMAGE_CUBETextureCubeMap
image2DArrayGL_IMAGE_2D_ARRAYTexture2DArray
iimage2DGL_INT_IMAGE_2DTexture2D
iimage3DGL_INT_IMAGE_3DTexture3D
iimageCubeGL_INT_IMAGE_CUBETextureCubeMap
iimage2DArrayGL_INT_IMAGE_2D_ARRAYTexture2DArray
uimage2DGL_UNSIGNED_INT_IMAGE_2DTexture2D
uimage3DGL_UNSIGNED_INT_IMAGE_3DTexture3D
uimageCubeGL_UNSIGNED_INT_IMAGE_CUBETextureCubeMap
uimage2DArrayGL_UNSIGNED_INT_IMAGE_2D_ARRAYTexture2DArray

OpenGL ES 3.2 supports all of the OpenGL ES 3.1 image types as well as the following:

GLSL TypeOpenGL Type EnumTexture Type
imageBufferGL_IMAGE_BUFFERTextureBuffer
imageCubeArrayGL_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray
iimageBufferGL_IMAGE_BUFFERTextureBuffer
iimageCubeArrayGL_INT_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray
uimageBufferGL_UNSIGNED_INT_IMAGE_BUFFERTextureBuffer
uimageCubeArrayGL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAYTextureCubeMapArray

Expected use would look like:

 import Qt3D.Render 2.14

 Entity {
 ...
     Texture2D {
         id: tex2D
         ...
     }

     Material {
         parameters: Parameter {
             name: "imageUniformName"
             value: ShaderImage {
                 texture: tex2D
             }
         }
         ...
     }
  ...
 }

Property Documentation

access : enumeration

Specifies the type of access we want to allow from our shader instances to the image. If a shader tries to write or read from an image that has incompatible access, the behavior is undefined.

ConstantDescription
ShaderImage.ReadOnlyRead-only access.
ShaderImage.WriteOnlyWrite-only access.
ShaderImage.ReadWriteRead-write access.

The default value is ShaderImage.ReadWrite.


format : enumeration

Specifies the image format, which is essentially important when storing values in the ShaderImage from a shader.

The format doesn't have to be the same as the referenced texture's format. It however has to be compatible (matching in size but not necessarily by class type). For instance a texture of format R32F (size 32bits, class 1x32) could be used with an image of format RGBA8I (size 32bits, class 4x8). Table 8.27 of the OpenGL specifications shows the size and class for all supported image formats.

By default Qt3D will try to set the image format to match that of the referenced texture.

The default value is ShaderImage.Automatic.


layer : int

Holds which layer out of the referenced texture should be used for the ShaderImage. This property does nothing if layered is set to true or if the reference texture's type isn't compatible with layers.

Note: When the referenced texture is of type cube map or cube map array and ĺayered is set to false, the face and layer are retrieved in the following manner:

 cubeMapLayer = layer / 6
 cubeMapFace = layer - (cubeMapLayer * 6)

The default value is 0.


layered : bool

*

If set to true, if the referenced texture is a one-dimensional array, two-dimensional array, three-dimensional, cube map, cube map array, or two-dimensional multisample array texture, the entire level will be bound for all layers. If set to false, only the single layer specified by the layer property will be bound.

The default value is false.


mipLevel : int

Holds which mipLevel out of the referenced texture should be used for the ShaderImage.

The default value is 0.