Texture sampler

Texture sampler

Sampling functions

Return type

Description

int

textureFilter enumeration

  1. textureFilter.point: No interpolation (nearest sample)

  2. textureFilter.linear: Linear interpolation between the 4 nearest texels

int

textureAddr enumeration

  1. textureAddr.clamp: Clamps UV coordinates to the [0, 1] range

  2. textureAddr.wrap: Wraps UV coordinates that are outside the [0, 1] range back into [0, 1] ("Repeat" mode)

float4

SamplerName.sample(float2 uv [, int filterMode [, int wrapMode]])
Samples a texel on the texture at the specified UV coordinates in parameter uv.

float4

SamplerName.sample(float subRectId, float2 uv [, int filterMode [, int wrapMode]])
Samples a texel on the texture atlas at the specified UV coordinates in parameter uv and atlas tile subRectId.
subRectId is in the [0, atlasRectCount-1] range

float2

SamplerName.remapDensity(float2 uv [, int filterMode [, int wrapMode]])
Builds a new UV from the input uv so that the final UV distribution matches the density of the texture.

float2

SamplerName.remapDensity(float subRectId, float2 uv [, int filterMode [, int wrapMode]])
Builds a new UV from the input uv so that the final UV distribution matches the density of the texture atlas tile subRectId.
subRectId is in the [0, atlasRectCount-1] range

float2

SamplerName.sampleDensity([int filterMode [, int wrapMode]])
Builds a random UV coordinate so that the final UV distribution matches the density of the texture.

float2

SamplerName.sampleDensity(float subRectId [, int filterMode [, int wrapMode]])
Returns a float2 containing the texture texel dimensions.
(can be just an abstract aspect ratio if the sampler is an attribute sampler overriden by the game engine and is a procedural 'infinite' texture rather than a physical texture).

Properties

Return type

Description

float2

SamplerName.dimensions()
Returns a float2 containing the texture texel dimensions.

int

SamplerName.atlasRectCount()
Returns the number of sub-rectangles in the texture atlas. Returns zero if there’s no atlas.

Disclaimer: These are describing the reference implementation. When using attribute samplers, the behavior of these functions can vary depending on the implementation in the game-engine where the effect is loaded.