Intrinsics1 min read
gather_offset
Gathers four texel values from an offset 2x2 footprint.
Reading Time
1 min
Word Count
120
Sections
7
Try It Live
Test gather_offset in a live shader
Open the playground, start from a visual preset, and wire gather_offset into the fragment stage to see how it behaves with real values.
Open PlaygroundThe gather_offset function gathers one component from four texels in a 2x2 footprint after applying an integer texel offset to the lookup location.
Live Demo
Signature
bwsl
gather_offset :: (texture2D tex, sampler samp, float2 uv, int component, int2 offset) -> float4 {...}
Parameters
| Parameter | Type | Description |
|---|---|---|
tex | texture2D | Texture to gather from |
samp | sampler | Sampler state |
uv | float2 | Texture coordinates |
component | int | Component to gather, where 0=R, 1=G, 2=B, 3=A |
offset | int2 | Integer texel offset applied to the gather footprint |
Return Value
Returns a float4 containing the selected component from the offset 2x2 texel footprint.
Example
bwsl
float4 center = gather(heightMap, uv, 0);
float4 right = gather_offset(heightMap, uv, 0, int2(1, 0));Compiled Output
When compiled to GLSL:
glsl
textureGatherOffset(tex, uv, offset, component)
See Also
- gather - Gather without offset
- sample_offset - Offset filtered sample
- load_offset - Offset texel fetch