Intrinsics1 min read

load_offset

Loads a texel directly using integer coordinates plus an offset.

Reading Time
1 min
Word Count
105
Sections
7
Try It Live

Test load_offset in a live shader

Open the playground, start from a visual preset, and wire load_offset into the fragment stage to see how it behaves with real values.

Open Playground

The load_offset function reads a texel at integer coordinates plus a constant integer offset. It performs an exact texel fetch without filtering.

Live Demo

Signature

bwsl
load_offset :: (texture2D tex, int2 coord, int mip, int2 offset) -> float4 {...}
load_offset :: (texture3D tex, int3 coord, int mip, int3 offset) -> float4 {...}

Parameters

ParameterTypeDescription
textexture*Texture to fetch from
coordint2/3Integer texel coordinate
mipintMip level to read
offsetint2/3Integer texel offset added to coord

Return Value

Returns the exact texel value at coord + offset and the selected mip level.

Example

bwsl
float4 center = load(inputTex, pixel, 0);
float4 right = load_offset(inputTex, pixel, 0, int2(1, 0));
float4 up = load_offset(inputTex, pixel, 0, int2(0, 1));

Compiled Output

When compiled to GLSL:

glsl
texelFetchOffset(tex, coord, mip, offset)

See Also