Texture

class nvisii.texture(*args, **kwargs)

The “Texture” component describes a 2D pattern used to drive the “Material” component’s parameters.

static are_any_dirty()

Indicates whether or not any entities are “out of date” and need to be updated through the “update components” function

static clear_all()

Clears any existing Texture components.

static create_add(name, a, b, hdr=False)

Constructs a Texture with the given name that adds two different textures together. :type name: string :param name: The name of the texture to create. :type a: Texture :param a: The first of two textures to add. :type b: Texture :param b: The second of two textures to add. :type hdr: boolean, optional :param hdr: If true, represents the channels of the texture using 32 bit floats. Otherwise, textures are stored natively using 8 bits per channel. :rtype: Texture :return: a Texture allocated by the renderer.

static create_from_data(name, width, height, data, linear=True, hdr=False)

Constructs a Texture with the given name from custom user data. :type name: string :param name: The name of the texture to create. :type width: int :param width: The width of the image. :type height: int :param height: The height of the image. :type data: float :param data: A row major flattened vector of RGBA texels. The length of this vector should be 4 * width * height. :type linear: boolean, optional :param linear: Indicates the image is already linear and should not be gamma corrected. Note, defaults to True for this function. :type hdr: boolean, optional :param hdr: If true, represents the channels of the texture using 32 bit floats. Otherwise, textures are stored natively using 8 bits per channel. :rtype: Texture :return: a Texture allocated by the renderer.

static create_from_file(name, path, linear=False)

Constructs a Texture with the given name from a file. :type name: string :param name: The name of the texture to create.

Supported formats include JPEG, PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM, KTX, and DDS

Parameters
  • path (string) – The path to the image.

  • linear (boolean, optional) – Indicates the image is already linear and should not be gamma corrected. Ignored for KTX, DDS, and HDR formats.

Return type

Texture

Returns

a Texture allocated by the renderer.

static create_from_image(name, path, linear=False)

Deprecated. Please use createFromFile.

static create_hsv(name, tex, hue, saturation, value, mix=1.0, hdr=False)

Constructs a Texture with the given name by applying a color transformation on the HSV space to an existing texture. :type name: string :param name: The name of the texture to create. :param t: The texture to take pixels from :type hue: float :param hue: Specifies the hue rotation of the image. 360 degrees are mapped to [0,1].

The hue shifts of 0 (-180) and 1 (180) have the same result.

Parameters
  • saturation (float) – A saturation of 0 removes hues from the image, resulting in a grayscale image. A shift greater than 1.0 increases saturation.

  • value (float) – is the overall brightness of the image. De/Increasing values shift an image darker/lighter.

  • mix (float, optional) – A value between 0 and 1 used to mix between the original input and the HSV transformed image.

  • hdr (boolean, optional) – If true, represents the channels of the texture using 32 bit floats. Otherwise, textures are stored natively using 8 bits per channel.

Return type

Texture

Returns

a Texture allocated by the renderer.

static create_mix(name, a, b, mix=1.0, hdr=False)

Constructs a Texture with the given name that mixes two different textures together. :type name: string :param name: The name of the texture to create. :type a: Texture :param a: The first of two textures to mix. :type b: Texture :param b: The second of two textures to mix. :type mix: float, optional :param mix: A value between 0 and 1 used to mix between the first and second textures. :type hdr: boolean, optional :param hdr: If true, represents the channels of the texture using 32 bit floats. Otherwise, textures are stored natively using 8 bits per channel. :rtype: Texture :return: a Texture allocated by the renderer.

static create_multiply(name, a, b, hdr=False)

Constructs a Texture with the given name that multiplies two different textures together. :type name: string :param name: The name of the texture to create. :type a: Texture :param a: The first of two textures to multiply. :type b: Texture :param b: The second of two textures to multiply. :type hdr: boolean, optional :param hdr: If true, represents the channels of the texture using 32 bit floats. Otherwise, textures are stored natively using 8 bits per channel. :rtype: Texture :return: a Texture allocated by the renderer.

static get(name)
Parameters

name (string) – The name of the Texture to get

Return type

Texture

Returns

a Texture who’s name matches the given name

get_byte_texels()
Return type

std::vector< u8vec4,std::allocator< u8vec4 > >

Returns

a flattened list of 8-bit texels

static get_count()
Return type

int

Returns

the number of allocated textures

static get_dirty_textures()
Return type

std::set< nvisii::Texture * >

Returns

a list of textures that have been modified since the previous frame

static get_edit_mutex()

For internal use. Returns the mutex used to lock entities for processing by the renderer.

get_float_texels()
Return type

std::vector< vec4,std::allocator< vec4 > >

Returns

a flattened list of 32-bit float texels

static get_front()
Return type

Texture

Returns

a pointer to the table of Texture components

static get_front_struct()
Return type

TextureStruct

Returns

a pointer to the table of TextureStructs

get_height()
Return type

int

Returns

the height of the texture in texels

get_id()
Return type

int

Returns

the unique integer ID for this component

get_name()
Return type

string

Returns

the name of this component

static get_name_to_id_map()
Return type

std::map< std::string,uint32_t,std::less< std::string >,std::allocator< std::pair< std::string const,uint32_t > > >

Returns

A map whose key is a texture name and whose value is the ID for that texture

get_width()
Return type

int

Returns

the width of the texture in texels

static initialize_factory(max_components)

Allocates the tables used to store all Texture components

static is_factory_initialized()
Return type

boolean

Returns

True if the tables used to store all Texture components have been allocated, and False otherwise

is_hdr()
Return type

boolean

Returns

True if the texture contains any values above 1

is_initialized()
Return type

boolean

Returns

True the current Texture is a valid, initialized Texture, and False if the Texture was cleared or removed.

is_linear()
Return type

boolean

Returns

True if the texture is represented linearly. Otherwise, the texture is in sRGB space

mark_dirty()

Tags the current component as being modified since the previous frame.

static remove(name)
Parameters

name (string) – The name of the Texture to remove

sample_byte_texels(uv)

Sample the texture at the given texture coordinates :type uv: vec2 :param uv: A pair of values between [0,0] and [1,1] :rtype: u8vec4 :return: a sampled texture value

sample_float_texels(uv)

Sample the texture at the given texture coordinates :type uv: vec2 :param uv: A pair of values between [0,0] and [1,1] :rtype: vec4 :return: a sampled texture value

set_linear(is_linear)
Parameters

is_linear (boolean) – If True, texels will be interpreted as linear space. Otherwise, the texels will be interpreed as sRGB space

set_scale(scale)

Sets the “scale” of a texture. Useful for patterns that repeat, eg tiles. Under the hood, this scales the texture coordinates of the object this texture influences. :type scale: vec2 :param scale: The scale of the texture. A value of [.5,.5] will cause a texture to take

up half the footprint in UV space of the original texture, effectively causing the texture to repeat in a pattern. Textures can be flipped in either U and/or V using negative scales.

property thisown

The membership flag

to_string()
Return type

string

Returns

a json string representation of the current component

static update_components()

Iterates through all components, updating any component struct fields and marking components as clean.