Intrinsics1 min read
sample_lod_offset
Samples a texture at an explicit mip level with an integer texel offset.
Reading Time
1 min
Word Count
123
Sections
7
Try It Live
Test sample_lod_offset in a live shader
Open the playground, start from a visual preset, and wire sample_lod_offset into the fragment stage to see how it behaves with real values.
Open PlaygroundThe sample_lod_offset function samples a texture at a specified mip level while applying an integer texel offset. It is useful for fixed-neighborhood reads where you also need explicit LOD control.
Live Demo
Signature
bwsl
sample_lod_offset :: (texture2D tex, sampler samp, float2 uv, float lod, int2 offset) -> float4 {...}
Parameters
| Parameter | Type | Description |
|---|---|---|
tex | texture2D | Texture to sample |
samp | sampler | Sampler state |
uv | float2 | Texture coordinates |
lod | float | Explicit mip level |
offset | int2 | Integer texel offset applied to the sample |
Return Value
Returns the sample value from the requested mip level and offset.
Example
bwsl
float lod = roughness * maxMip;
float4 shifted = sample_lod_offset(envTexture, uv, lod, int2(2, 0));Compiled Output
When compiled to GLSL:
glsl
textureLodOffset(tex, uv, lod, offset)
See Also
- sample_lod - Explicit LOD sampling
- sample_offset - Automatic LOD with offset
- texture_levels - Query mip level count