GLSL built-in function
textureLod()
Samples using an explicit floating-point mip level.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureLod(gsampler2D sampler, vec2 coord, float lod)Parameters
- sampler
- Bound fixture texture
- coord
- Lookup coordinate
- lod
- Mip level; zero is full resolution
Return value
Four sampled components at an explicit floating-point mip level; filtering may blend texels and adjacent mip levels.
Live example
Edit the code and the preview updates as you type.
What textureLod does
Samples using an explicit floating-point mip level.
Read the preview
u_parameter*7.0 selects increasingly coarse mip levels as the slider rises. Replace the expression with 0.0 to hold the generated GLSL lettering at full texture resolution.
Core call
textureLod(u_texture,uv,u_parameter*7.0).rgb;
Generate mipmaps before expecting meaningful coarse mip-level results.
Experiment
Set the LOD argument in textureLod to 6.0. The 256-pixel fixture is sampled near its 4-pixel mip size, so grid lines and letters merge into broad colors.