ProceduralTextureData QML Type

Allows creation and population of TextureData from QML. More...

Import Statement: import QtQuick3D.Helpers
Since: Qt 6.6
Inherits:

TextureData

Properties

Detailed Description

ProceduralTextureData is a helper type that allows creation of TextureData from QML. The TextureData component is Abstract, and is usually created from C++. With ProceduralTextureData, it is possible to populate a TextureData from QML.

ProceduralTextureData {
    id: dynamicTextureData
    property color color1: "red"
    property color color2: "black"
    width: 32
    height: 32
    hasTransparency: false
    format: TextureData.RGBA8
    textureData: generateTextureData(color1, color2)

    function generateTextureData(newColor1: color, newColor2 : color) : ArrayBuffer {
        let dataBuffer = new ArrayBuffer(width * height * 4)
        let data = new Uint8Array(dataBuffer)
        // Create a checkered pattern using newColor1 and newColor2
        for (let x = 0; x < width; x++) {
            for (let y = 0; y < height; y++) {
                let index = (x + y * width) * 4
                let color = (x % 2 === y % 2) ? newColor1 : newColor2
                data[index + 0] = color.r * 255
                data[index + 1] = color.g * 255
                data[index + 2] = color.b * 255
                data[index + 3] = 255
            }
        }
        return dataBuffer
    }
}

In the above code snippet, the function generateTextureData is used to generate a checkerboard pattern using the two colors color1 and color2. By filling an ArrayBuffer with the generated data, the textureData property of the TextureData is populated.

Property Documentation

depth : int [default: 0]

This property holds the depth of the texture data in pixels. Setting the depth above 0 means that the texture is handled as a 3D texture.


format : enumeration [default: TextureData.RGBA8]

This property holds the format of the texture data.

ConstantDescription
TexureData.NoneThe color format is not defined
TexureData.RGBA8The color format is considered as 8-bit integer in R, G, B and alpha channels.
TexureData.RGBA16FThe color format is considered as 16-bit float in R,G,B and alpha channels.
TexureData.RGBA32FThe color format is considered as 32-bit float in R, G, B and alpha channels.
TexureData.RGBE8The color format is considered as 8-bit mantissa in the R, G, and B channels and 8-bit shared exponent.
TexureData.R8The color format is considered as 8-bit integer in R channel.
TexureData.R16The color format is considered as 16-bit integer in R channel.
TexureData.R16FThe color format is considered as 16-bit float in R channel.
TexureData.R32FThe color format is considered as 32-bit float R channel.
TexureData.BC1The color format is considered as BC1 compressed format with R, G, B, and alpha channels.
TexureData.BC2The color format is considered as BC2 compressed format with R, G, B, and alpha channels.
TexureData.BC3The color format is considered as BC3 compressed format with R, G, B, and alpha channels.
TexureData.BC4The color format is considered as BC4 compressed format with one color channel.
TexureData.BC5The color format is considered as BC5 compressed format with two color channels.
TexureData.BC6HThe color format is considered as BC6H compressed format with three high dynamic range color channels.
TexureData.BC7The color format is considered as BC7 compressed format with R, G, B, and alpha channels.
TexureData.DXT1_RGBAThe color format is considered as DXT1 compressed format with R, G, B and alpha channels.
TexureData.DXT1_RGBThe color format is considered as DXT1 compressed format with R, G and B channels.
TexureData.DXT3_RGBAThe color format is considered as DXT3 compressed format with R, G, B and alpha channels.
TexureData.DXT5_RGBAThe color format is considered as DXT5 compressed format with R, G, B and alpha channels.
TexureData.ETC2_RGB8The color format is considered as ETC2 compressed format for RGB888 data
TexureData.ETC2_RGB8A1The color format is considered as ETC2 compressed format for RGBA data where alpha is 1-bit.
TexureData.ETC2_RGBA8The color format is considered as ETC2 compressed format with RGBA8888 data.
TexureData.ASTC_4x4The color format is considered as ASTC compressed format with 4x4 block footprint.
TexureData.ASTC_5x4The color format is considered as ASTC compressed format with 5x4 block footprint.
TexureData.ASTC_5x5The color format is considered as ASTC compressed format with 5x5 block footprint.
TexureData.ASTC_6x5The color format is considered as ASTC compressed format with 6x5 block footprint.
TexureData.ASTC_6x6The color format is considered as ASTC compressed format with 6x6 block footprint.
TexureData.ASTC_8x5The color format is considered as ASTC compressed format with 8x5 block footprint.
TexureData.ASTC_8x6The color format is considered as ASTC compressed format with 8x6 block footprint.
TexureData.ASTC_8x8The color format is considered as ASTC compressed format with 8x8 block footprint.
TexureData.ASTC_10x5The color format is considered as ASTC compressed format with 10x5 block footprint.
TexureData.ASTC_10x6The color format is considered as ASTC compressed format with 10x6 block footprint.
TexureData.ASTC_10x8The color format is considered as ASTC compressed format with 10x8 block footprint.
TexureData.ASTC_10x10The color format is considered as ASTC compressed format with 10x10 block footprint.
TexureData.ASTC_12x10The color format is considered as ASTC compressed format with 12x10 block footprint.
TexureData.ASTC_12x12The color format is considered as ASTC compressed format with 12x12 block footprint.

Note: With the exception of TexureData.RGBA8, not every format is supported at runtime as this depends on which backend is being used as well which hardware is being used.

Note: TexureData.RGBE is internally represented as an TexureData.RGBA8 but is interpreted as described when used as a lightProbe or skybox texture.

Note: Using the value TexureData.None will assume the default value of TexureData.RGBA8


hasTransparency : bool

This property holds whether the texture data has transparency.


height : int [default: 0]

This property holds the height of the texture data in pixels.


textureData : ArrayBuffer

This property holds the texture data.


width : int [default: 0]

This property holds the width of the texture data in pixels.


© 2024 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.