PopcornFX v2.19

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
  1. Home
  2. Docs
  3. PopcornFX v2.19
  4. Scripting reference
  5. Samplers
  6. Texture sampler

Texture sampler

Texture sampler

Sampling functions

Return typeDescription
inttextureFilter enumeration
Can be passed in the filterMode argument of the sampling functions below.

  1. textureFilter.point: No interpolation (nearest sample)
  2. textureFilter.linear: Linear interpolation between the 4 nearest texels
inttextureAddr enumeration
Can be passed in the wrapMode argument of the sampling functions below.

  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)
float4SamplerName.sample(float2 uv [, int filterMode [, int wrapMode]])
Samples a texel on the texture at the specified UV coordinates in parameter uv.
float4SamplerName.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
float2SamplerName.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.
float2SamplerName.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
float2SamplerName.sampleDensity([int filterMode [, int wrapMode]])
Builds a random UV coordinate so that the final UV distribution matches the density of the texture.
float2SamplerName.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).
float4SamplerName.read(int texelId) [v2.16.0]
Performs a fast direct-read of the texture using the input texelId. In a 64x64 texture, calling the function with ID = 0 will output the value of the first texel, calling it with ID = 63 will read the last texel of the first row, ID = 4095 will read the last texel of the last row. You can use the texel*ToID() set of functions to convert from UVs or x,y texel coordinates to flat texelIDs suitable to give to this function.
floatSamplerName.readChannel(int texelId, int channelId) [v2.16.0]
Performs a fast direct-read of the texture using the input texelId. The function will output the channel channelID of the texel.
channelID must be a per-wave or constant value, and cannot vary per-particle. The accepted values are 0, 1, 2, or 3, for R, G, B, and A channels respectively.
See the wave functions scripting page for more information on per-waves values.
int2SamplerName.texelUVToCoords(float2 uv [, int wrapMode]) [v2.16.0]
Converts from [0,1] UV coordinates to x,y integer texel coordinates.
intSamplerName.texelUVToID(float2 uv [, int wrapMode]) [v2.16.0]
Converts from [0,1] UV coordinates to flat texel IDs.
float2SamplerName.texelCoordsToUV(int2 texelCoords) [v2.16.0]
Converts from x,y integer texel coordinates to [0,1] UV coordinates.
intSamplerName.texelCoordsToID(int2 texelCoords) [v2.16.0]
Converts from x,y integer texel coordinates to flat texel IDs.
float2SamplerName.texelIDToUV(int texelId) [v2.16.0]
Converts from flat texel IDs to [0,1] UV coordinates.
int2SamplerName.texelIDToCoords(int texelId) [v2.16.0]
Converts from flat texel IDs to x,y integer texel coordinates.
float2SamplerName.texelUVToFrac(float2 uv [, int wrapMode]) [v2.16.0]
Extracts the fractional sub-texel lerp factors from the input UV.
float2SamplerName.texelSubUVToGlobalUV(float2 uv, float subRectId [, int wrapMode]]) [v2.16.0]
Converts a sub-UV in the image atlas at the specified UV coordinates uv and atlas tile subRectId, into a global texture UV suitable to then be converted to flat IDs or x,y integer texel coordinates.

 

Properties

Return typeDescription
float2SamplerName.dimensions()
Returns a float2 containing the texture texel dimensions.
intSamplerName.atlasRectCount()
Returns the number of sub-rectangles in the texture atlas. Returns zero if there’s no atlas.

 

Note: 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.

Was this article helpful to you? Yes No

How can we help?