Intrinsics1 min read
sample_offset
Samples a texture with an integer texel offset.
Reading Time
1 min
Word Count
118
Sections
7
Try It Live
Test sample_offset in a live shader
Open the playground, start from a visual preset, and wire sample_offset into the fragment stage to see how it behaves with real values.
Open PlaygroundThe sample_offset function samples a texture at UV coordinates plus a constant integer texel offset. Use it for small fixed kernels such as blur taps, edge detection, and neighborhood lookups that still use filtered sampling.
Live Demo
Signature
bwsl
sample_offset :: (texture2D tex, sampler samp, float2 uv, int2 offset) -> float4 {...}
Parameters
| Parameter | Type | Description |
|---|---|---|
tex | texture2D | Texture to sample |
samp | sampler | Sampler state |
uv | float2 | Texture coordinates |
offset | int2 | Integer texel offset applied to the sample |
Return Value
Returns the filtered sample value from the offset texture coordinate.
Example
bwsl
float4 center = sample(resources.albedo, resources.albedoSampler, uv);
float4 right = sample_offset(resources.albedo, resources.albedoSampler, uv, int2(1, 0));
float4 up = sample_offset(resources.albedo, resources.albedoSampler, uv, int2(0, 1));Compiled Output
When compiled to GLSL:
glsl
textureOffset(tex, uv, offset)
See Also
- sample - Basic filtered sampling
- sample_lod_offset - Explicit LOD with offset
- gather_offset - Gather with offset