ProceduralTextureData QML Type
Allows creation and population of TextureData from QML. More...
Import Statement: | import QtQuick3D.Helpers |
Since: | Qt 6.6 |
Inherits: |
Properties
- depth : int
- format : enumeration
- hasTransparency : bool
- height : int
- textureData : ArrayBuffer
- width : int
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 |
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 |
This property holds the format of the texture data.
Constant | Description |
---|---|
TexureData.None | The color format is not defined |
TexureData.RGBA8 | The color format is considered as 8-bit integer in R, G, B and alpha channels. |
TexureData.RGBA16F | The color format is considered as 16-bit float in R,G,B and alpha channels. |
TexureData.RGBA32F | The color format is considered as 32-bit float in R, G, B and alpha channels. |
TexureData.RGBE8 | The color format is considered as 8-bit mantissa in the R, G, and B channels and 8-bit shared exponent. |
TexureData.R8 | The color format is considered as 8-bit integer in R channel. |
TexureData.R16 | The color format is considered as 16-bit integer in R channel. |
TexureData.R16F | The color format is considered as 16-bit float in R channel. |
TexureData.R32F | The color format is considered as 32-bit float R channel. |
TexureData.BC1 | The color format is considered as BC1 compressed format with R, G, B, and alpha channels. |
TexureData.BC2 | The color format is considered as BC2 compressed format with R, G, B, and alpha channels. |
TexureData.BC3 | The color format is considered as BC3 compressed format with R, G, B, and alpha channels. |
TexureData.BC4 | The color format is considered as BC4 compressed format with one color channel. |
TexureData.BC5 | The color format is considered as BC5 compressed format with two color channels. |
TexureData.BC6H | The color format is considered as BC6H compressed format with three high dynamic range color channels. |
TexureData.BC7 | The color format is considered as BC7 compressed format with R, G, B, and alpha channels. |
TexureData.DXT1_RGBA | The color format is considered as DXT1 compressed format with R, G, B and alpha channels. |
TexureData.DXT1_RGB | The color format is considered as DXT1 compressed format with R, G and B channels. |
TexureData.DXT3_RGBA | The color format is considered as DXT3 compressed format with R, G, B and alpha channels. |
TexureData.DXT5_RGBA | The color format is considered as DXT5 compressed format with R, G, B and alpha channels. |
TexureData.ETC2_RGB8 | The color format is considered as ETC2 compressed format for RGB888 data |
TexureData.ETC2_RGB8A1 | The color format is considered as ETC2 compressed format for RGBA data where alpha is 1-bit. |
TexureData.ETC2_RGBA8 | The color format is considered as ETC2 compressed format with RGBA8888 data. |
TexureData.ASTC_4x4 | The color format is considered as ASTC compressed format with 4x4 block footprint. |
TexureData.ASTC_5x4 | The color format is considered as ASTC compressed format with 5x4 block footprint. |
TexureData.ASTC_5x5 | The color format is considered as ASTC compressed format with 5x5 block footprint. |
TexureData.ASTC_6x5 | The color format is considered as ASTC compressed format with 6x5 block footprint. |
TexureData.ASTC_6x6 | The color format is considered as ASTC compressed format with 6x6 block footprint. |
TexureData.ASTC_8x5 | The color format is considered as ASTC compressed format with 8x5 block footprint. |
TexureData.ASTC_8x6 | The color format is considered as ASTC compressed format with 8x6 block footprint. |
TexureData.ASTC_8x8 | The color format is considered as ASTC compressed format with 8x8 block footprint. |
TexureData.ASTC_10x5 | The color format is considered as ASTC compressed format with 10x5 block footprint. |
TexureData.ASTC_10x6 | The color format is considered as ASTC compressed format with 10x6 block footprint. |
TexureData.ASTC_10x8 | The color format is considered as ASTC compressed format with 10x8 block footprint. |
TexureData.ASTC_10x10 | The color format is considered as ASTC compressed format with 10x10 block footprint. |
TexureData.ASTC_12x10 | The color format is considered as ASTC compressed format with 12x10 block footprint. |
TexureData.ASTC_12x12 | The 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 |
This property holds the height of the texture data in pixels.
textureData : ArrayBuffer |
This property holds the texture data.
width : int |
This property holds the width of the texture data in pixels.