class QShaderImage#

Provides Image access to shader programs. More

Inheritance diagram of PySide6.Qt3DRender.Qt3DRender.QShaderImage

Synopsis#

Properties#

Methods#

Slots#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

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

class 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+)

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property accessᅟ: Qt3DRender.QShaderImage.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 .

Access functions:
property formatᅟ: Qt3DRender.QShaderImage.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 .

Access functions:
property 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.

Access functions:
property 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.

Access functions:
property mipLevelᅟ: int#

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

The default value is 0.

Access functions:
property textureᅟ: QAbstractTexture#
Access functions:
__init__([parent=None])#
Parameters:

parentQNode

access()#
Return type:

Access

See also

setAccess()

Getter of property accessᅟ .

accessChanged(access)#
Parameters:

accessAccess

Notification signal of property accessᅟ .

format()#
Return type:

ImageFormat

See also

setFormat()

Getter of property formatᅟ .

formatChanged(format)#
Parameters:

formatImageFormat

Notification signal of property formatᅟ .

layer()#
Return type:

int

See also

setLayer()

Getter of property layerᅟ .

layerChanged(layer)#
Parameters:

layer – int

Notification signal of property layerᅟ .

layered()#
Return type:

bool

See also

setLayered()

Getter of property layeredᅟ .

layeredChanged(layered)#
Parameters:

layered – bool

Notification signal of property layeredᅟ .

mipLevel()#
Return type:

int

See also

setMipLevel()

Getter of property mipLevelᅟ .

mipLevelChanged(mipLevel)#
Parameters:

mipLevel – int

Notification signal of property mipLevelᅟ .

setAccess(access)#
Parameters:

accessAccess

See also

access()

Setter of property accessᅟ .

setFormat(format)#
Parameters:

formatImageFormat

See also

format()

Setter of property formatᅟ .

setLayer(layer)#
Parameters:

layer – int

See also

layer()

Setter of property layerᅟ .

setLayered(layered)#
Parameters:

layered – bool

See also

layered()

Setter of property layeredᅟ .

setMipLevel(mipLevel)#
Parameters:

mipLevel – int

See also

mipLevel()

Setter of property mipLevelᅟ .

setTexture(texture)#
Parameters:

textureQAbstractTexture

See also

texture()

Setter of property textureᅟ .

texture()#
Return type:

QAbstractTexture

See also

setTexture()

Getter of property textureᅟ .

textureChanged(texture)#
Parameters:

textureQAbstractTexture

Notification signal of property textureᅟ .