ShaderImage QML Type

Provides Image access to shader programs. More...

Import Statement: import Qt3D.Render 2.14
Since: Qt 5.14
Instantiates: QShaderImage

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
              }
          }
          ...
      }
   ...
  }