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 PlaygroundThe 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
| Parameter | Type | Description |
|---|---|---|
tex | texture* | Texture to fetch from |
coord | int2/3 | Integer texel coordinate |
mip | int | Mip level to read |
offset | int2/3 | Integer 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
- load - Direct texel fetch
- sample_offset - Filtered offset sample
- gather_offset - Offset gather