QShaderImage

Provides Image access to shader programs. More

Inheritance diagram of PySide6.Qt3DRender.Qt3DRender.QShaderImage

New in version 5.14.

Synopsis

Functions

Slots

Signals

Detailed Description

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

QShaderImage has to be assigned as a QParameter ‘s value and reference a valid QAbstractTexture 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 QShaderImage is only supported with OpenGL 4 and partially with OpenGL ES 3.1 and 3.2.

OpenGL 4 supports the following image types:

GLSL Type

OpenGL Type Enum

Texture Type

image1D

GL_IMAGE_1D

QTexture1D

image2D

GL_IMAGE_2D

QTexture2D

image3D

GL_IMAGE_3D

QTexture3D

image2DRect

GL_IMAGE_2D_RECT

QTextureRectangle

imageCube

GL_IMAGE_CUBE

QTextureCubeMap

imageBuffer

GL_IMAGE_BUFFER

QTextureBuffer

image1DArray

GL_IMAGE_1D_ARRAY

QTexture1DArray

image2DArray

GL_IMAGE_2D_ARRAY

QTexture2DArray

imageCubeArray

GL_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

image2DMS

GL_IMAGE_2D_MULTISAMPLE

QTexture2DMultisample

image2DMSArray

GL_IMAGE_2D_MULTISAMPLE_ARRAY

QTexture2DMultisampleArray

iimage1D

GL_INT_IMAGE_1D

QTexture1D

iimage2D

GL_INT_IMAGE_2D

QTexture2D

iimage3D

GL_INT_IMAGE_3D

QTexture3D

iimage2DRect

GL_INT_IMAGE_2D_RECT

QTextureRectangle

iimageCube

GL_INT_IMAGE_CUBE

QTextureCubeMap

iimageBuffer

GL_INT_IMAGE_BUFFER

QTextureBuffer

iimage1DArray

GL_INT_IMAGE_1D_ARRAY

QTexture1DArray

iimage2DArray

GL_INT_IMAGE_2D_ARRAY

QTexture2DArray

iimageCubeArray

GL_INT_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

iimage2DMS

GL_INT_IMAGE_2D_MULTISAMPLE

QTexture2DMultisample

iimage2DMSArray

GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY

QTexture2DMultisampleArray

uimage1D

GL_UNSIGNED_INT_IMAGE_1D

QTexture1D

uimage2D

GL_UNSIGNED_INT_IMAGE_2D

QTexture2D

uimage3D

GL_UNSIGNED_INT_IMAGE_3D

QTexture3D

uimage2DRect

GL_UNSIGNED_INT_IMAGE_2D_RECT

QTextureRectangle

uimageCube

GL_UNSIGNED_INT_IMAGE_CUBE

QTextureCubeMap

uimageBuffer

GL_UNSIGNED_INT_IMAGE_BUFFER

QTextureBuffer

uimage1DArray

GL_UNSIGNED_INT_IMAGE_1D_ARRAY

QTexture1DArray

uimage2DArray

GL_UNSIGNED_INT_IMAGE_2D_ARRAY

QTexture2DArray

uimageCubeArray

GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

uimage2DMS

GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE

QTexture2DMultisample

uimage2DMSArray

GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY

QTexture2DMultisampleArray

OpenGL ES 3.1 supports the following image types:

GLSL Type

OpenGL Type Enum

Texture Type

image2D

GL_IMAGE_2D

QTexture2D

image3D

GL_IMAGE_3D

QTexture3D

imageCube

GL_IMAGE_CUBE

QTextureCubeMap

image2DArray

GL_IMAGE_2D_ARRAY

QTexture2DArray

iimage2D

GL_INT_IMAGE_2D

QTexture2D

iimage3D

GL_INT_IMAGE_3D

QTexture3D

iimageCube

GL_INT_IMAGE_CUBE

QTextureCubeMap

iimage2DArray

GL_INT_IMAGE_2D_ARRAY

QTexture2DArray

uimage2D

GL_UNSIGNED_INT_IMAGE_2D

QTexture2D

uimage3D

GL_UNSIGNED_INT_IMAGE_3D

QTexture3D

uimageCube

GL_UNSIGNED_INT_IMAGE_CUBE

QTextureCubeMap

uimage2DArray

GL_UNSIGNED_INT_IMAGE_2D_ARRAY

QTexture2DArray

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

GLSL Type

OpenGL Type Enum

Texture Type

imageBuffer

GL_IMAGE_BUFFER

QTextureBuffer

imageCubeArray

GL_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

iimageBuffer

GL_IMAGE_BUFFER

QTextureBuffer

iimageCubeArray

GL_INT_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

uimageBuffer

GL_UNSIGNED_INT_IMAGE_BUFFER

QTextureBuffer

uimageCubeArray

GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY

QTextureCubeMapArray

Expected use would look like:

Qt3DRender::QTexture2D *tex2D = new Qt3DRender::QTexture2D();
...
Qt3DRender::QMaterial *material = new Qt3DRender::QMaterial();
...
Qt3DRender::QParameter *imageParameter = new Qt3DRender::QParameter();
Qt3DRender::QShaderImage *shaderImage = new Qt3DRender::QShaderImage();

shaderImage->setTexture(tex2D);

imageParameter->setName("imageUniformName");
imageParameter->setValue(QVariant::fromValue(shaderImage));

material->addParameter(imageParamenter);
class PySide6.Qt3DRender.Qt3DRender.QShaderImage([parent=None])
Parameters

parentPySide6.Qt3DCore.Qt3DCore.QNode

PySide6.Qt3DRender.Qt3DRender.QShaderImage.Access

Constant

Description

Qt3DRender.QShaderImage.ReadOnly

Image will only be read from in shaders

Qt3DRender.QShaderImage.WriteOnly

Image will only be written into from shaders

Qt3DRender.QShaderImage.ReadWrite

Image will only be read and written into from shaders

PySide6.Qt3DRender.Qt3DRender.QShaderImage.ImageFormat

This list describes all possible image formats

Constant

Description

Qt3DRender.QShaderImage.NoFormat

GL_NONE

Qt3DRender.QShaderImage.Automatic

Qt 3D will try to determine the format automatically based on the referenced texture.

Qt3DRender.QShaderImage.R8_UNorm

GL_R8 (GLSL type r8, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG8_UNorm

GL_RG8 (GLSL type rg8, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA8_UNorm

GL_RGBA8 (GLSL type rgba8, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R16_UNorm

GL_R16 (GLSL type r16, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG16_UNorm

GL_RG16 (GLSL type rg16, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA16_UNorm

GL_RGBA16 (GLSL type rgba16, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.R8_SNorm

GL_R8_SNORM (GLSL type r8_snorm, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG8_SNorm

GL_RG8_SNORM (GLSL type rg8_snorm, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA8_SNorm

GL_RGBA8_SNORM (GLSL type rgba8_snorm, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R16_SNorm

GL_R16_SNORM (GLSL type r16_snorm, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG16_SNorm

GL_RG16_SNORM (GLSL type rg16_snorm, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA16_SNorm

GL_RGBA16_SNORM (GLSL type rgba16_snorm, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.R8U

GL_R8UI (GLSL type r8ui, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG8U

GL_RG8UI (GLSL type rg8ui, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA8U

GL_RGBA8UI (GLSL type rgba8ui, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R16U

GL_R16UI (GLSL type r16ui, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG16U

GL_RG16UI (GLSL type rg16ui, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA16U

GL_RGBA16UI (GLSL type rgba16ui, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R32U

GL_R32UI (GLSL type r32ui, supported by OpenGL 4.2+, OpenGL ES 3.1)

Qt3DRender.QShaderImage.RG32U

GL_RG32UI (GLSL type rg32ui, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA32U

GL_RGBA32UI (GLSL type rgba32ui, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R8I

GL_R8I (GLSL type r8i, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG8I

GL_RG8I (GLSL type rg8i, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA8I

GL_RGBA8I (GLSL type rgba8i, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R16I

GL_R16I (GLSL type r16i, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG16I

GL_RG16I (GLSL type rg16i, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA16I

GL_RGBA16I (GLSL type rgba16i, supported by OpenGL 4.2+, OpenGL ES 3.1)

Qt3DRender.QShaderImage.R32I

GL_R32I (GLSL type r32i, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.RG32I

GL_RG32I (GLSL type rg32i, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA32I

GL_RGBA32I (GLSL type rgba32i, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R16F

GL_R16F (GLSL type r16f, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RG16F

GL_RG16F (GLSL type rg16f, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA16F

GL_RGBA16F (GLSL type rgba16f, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.R32F

GL_R32F (GLSL type r32f, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.RG32F

GL_RG32F (GLSL type rg32f, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGBA32F

GL_RGBA32F (GLSL type rgba32f, supported by OpenGL 4.2+, OpenGL ES 3.1+)

Qt3DRender.QShaderImage.RG11B10F

GL_R11F_G11F_B10F (GLSL type r11f_g11f_b10f, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGB10A2

GL_RGB10_A2 (GLSL type rgb10_a2, supported by OpenGL 4.2+)

Qt3DRender.QShaderImage.RGB10A2U

GL_RGB10_A2UI (GLSL type rgb10_a2ui, supported by OpenGL 4.2+)

PySide6.Qt3DRender.Qt3DRender.QShaderImage.access()
Return type

Access

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.

The default value is ReadWrite .

PySide6.Qt3DRender.Qt3DRender.QShaderImage.accessChanged(access)
Parameters

accessAccess

PySide6.Qt3DRender.Qt3DRender.QShaderImage.format()
Return type

ImageFormat

Specifies the image format, which is essentially important when storing values in the Image 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 Automatic .

PySide6.Qt3DRender.Qt3DRender.QShaderImage.formatChanged(format)
Parameters

formatImageFormat

PySide6.Qt3DRender.Qt3DRender.QShaderImage.layer()
Return type

int

Holds which layer out of the referenced texture should be used for the QShaderImage . 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.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.layerChanged(layer)
Parameters

layer – int

PySide6.Qt3DRender.Qt3DRender.QShaderImage.layered()
Return type

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.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.layeredChanged(layered)
Parameters

layered – bool

PySide6.Qt3DRender.Qt3DRender.QShaderImage.mipLevel()
Return type

int

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

The default value is 0.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.mipLevelChanged(mipLevel)
Parameters

mipLevel – int

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setAccess(access)
Parameters

accessAccess

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.

The default value is ReadWrite .

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setFormat(format)
Parameters

formatImageFormat

Specifies the image format, which is essentially important when storing values in the Image 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 Automatic .

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setLayer(layer)
Parameters

layer – int

Holds which layer out of the referenced texture should be used for the QShaderImage . 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.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setLayered(layered)
Parameters

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.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setMipLevel(mipLevel)
Parameters

mipLevel – int

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

The default value is 0.

PySide6.Qt3DRender.Qt3DRender.QShaderImage.setTexture(texture)
Parameters

texturePySide6.Qt3DRender.Qt3DRender.QAbstractTexture

PySide6.Qt3DRender.Qt3DRender.QShaderImage.texture()
Return type

PySide6.Qt3DRender.Qt3DRender.QAbstractTexture

PySide6.Qt3DRender.Qt3DRender.QShaderImage.textureChanged(texture)
Parameters

texturePySide6.Qt3DRender.Qt3DRender.QAbstractTexture