/  ChuGL Textures

Texture

TextureSampler

TextureDesc

TextureWriteDesc

TextureLoadDesc

Textures can be loaded from file, created dynamically from data; they are passed into materials and mapped onto 2D and 3D surfaces.

Texture

inherits : SG_Component : Object

Texture class. Immutable, meaning properties (e.g. format, dimension, size, mip levels) cannot be changed after creation. You can, however, write data to the texture.

examples

constructors

Texture()

Default constructor for Texture.

Texture(TextureDesc texture_desc)

No description available

member functions

int width()

Get the texture width (immutable)

void write(float[] pixel_data)

Convenience function for writing into a texture. Assumes pixel_data is being written into the texture origin (0,0,0) with a region equal to the full texture dimensions (width, height, depth) at mip level 0.

int format()

Get the texture format (immutable). Returns a value from the Texture.Format_XXXXX enum, e.g. Texture.Format_RGBA8Unorm.

int dimension()

Get the texture dimension (immutable). Returns a value from the Texture.Dimension_XXXXX enum, e.g. Texture.Dimension_2D.

int depth()

Get the texture depth (immutable). For a 2D texture, depth corresponds to the number of array layers (e.g. depth=6 for a cubemap)

int usage()

Get the texture usage flags (immutable). Returns a bitmask of usage flgas from the Texture.Usage_XXXXX enum e.g. Texture.Usage_TextureBinding | Texture.Usage_RenderAttachment. By default, textures are created with ALL usages enabled.

int mips()

Get the number of mip levels (immutable). Returns the number of mip levels in the texture.

int height()

Get the texture height (immutable)

void write(float[] pixel_data, TextureWriteDesc write_desc)

Write pixel data to an arbitrary texture region. The input float data is automatically converted based on the texture format.

static member functions

Texture load(string filepath)

Load a 2D texture from a file.

Texture load(string filepath, TextureLoadDesc load_desc)

Load a 2D texture from a file with additional parameters.

Texture load(string right, string left, string top, string bottom, string back, string front)

Load a cubemap texture from 6 filepaths, one for each face.

static member variables

int Usage_CopySrc

Texture usage flag: can be used as a source for copy/write operations.

int Usage_CopyDst

Texture usage flag: can be used destination for copy/write operations.

int Usage_TextureBinding

Texture usage flag: texture can be bound to a shader.

int Usage_StorageBinding

Texture usage flag: texture can be bound as a storage texture to a shader.

int Usage_RenderAttachment

Texture usage flag: texture can be used as a render attachment, i.e. written to by a render pass.

int Usage_All

Texture usage flag: all usages enabled.

int Dimension_2D

No description available

int Format_RGBA8Unorm

No description available

int Format_RGBA16Float

No description available

int Format_RGBA32Float

No description available

int Format_R32Float

No description available


TextureSampler

inherits : Object

Texture Sampler -- options for sampling a texture.

constructors

TextureSampler()

Default constructor for TextureSampler.

member variables

int wrapU

U-axis (horizontal) wrap mode. Valid values are TextureSampler.Wrap_Repeat, TextureSampler.Wrap_Mirror, TextureSampler.Wrap_Clamp.

int wrapV

V-axis (vertical) wrap mode. Valid values are TextureSampler.Wrap_Repeat, TextureSampler.Wrap_Mirror, TextureSampler.Wrap_Clamp.

int wrapW

W-axis wrap mode. Valid values are TextureSampler.Wrap_Repeat, TextureSampler.Wrap_Mirror, TextureSampler.Wrap_Clamp.

int filterMin

Minification filter. Valid values are TextureSampler.Filter_Nearest, TextureSampler.Filter_Linear.

int filterMag

Magnification filter. Valid values are TextureSampler.Filter_Nearest, TextureSampler.Filter_Linear.

int filterMip

Mip level filter. Valid values are TextureSampler.Filter_Nearest, TextureSampler.Filter_Linear.

static member variables

int Wrap_Repeat

No description available

int Wrap_Mirror

No description available

int Wrap_Clamp

No description available

int Filter_Nearest

No description available

int Filter_Linear

No description available


TextureDesc

inherits : Object

Texture Descriptor -- options for creating a texture.

constructors

TextureDesc()

Default constructor for TextureDesc.

member variables

int width

Width in texels. Default is 1.

int format

Texture format. Valid options are defined in the Texture.Format_* enum. Default is Texture.Format_RGBA8Unorm.

int dimension

Texture dimension. Valid options are defined in the Texture.Dimension_* enum. Default is Texture.Dimension_2D.

int depth

Depth in texels. Default is 1.

int usage

Bit mask of texture usage flags. Valid flags are defined in the Texture.Usage_* enum. Default is Texture.Usage_All, which enables all usages.

int mips

Number of mip levels. Default is 1.

int height

Height in texels. Default is 1.


TextureWriteDesc

inherits : Object

Options for writing to a texture.

constructors

TextureWriteDesc()

Default constructor for TextureWriteDesc.

member variables

int width

Width of write region. Default 0.

int y

Y offset of write region. Default 0.

int x

X offset of write region. Default 0.

int z

Z offset of write region. Default 0.

int depth

Depth of write region. Default 0.

int mip

Which mip level to write to. Default is 0 (base level)

int height

Height of write region. Default 0.


TextureLoadDesc

inherits : Object

Options for loading a texture from a file.

constructors

TextureLoadDesc()

Default constructor for TextureLoadDesc.

member variables

int flip_y

Flip the image vertically before loading. Default false.

int gen_mips

Generate mipmaps for the texture. Default true.