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 Playground

The 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

ParameterTypeDescription
textexture2DTexture to sample
sampsamplerSampler state
uvfloat2Texture coordinates
lodfloatExplicit mip level
offsetint2Integer 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