GLSL built-in function

texture2DProjLod()

Combines projected coordinates with an explicit mip level in a vertex shader.

Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Vertex

Syntax

vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod)

Parameters

sampler
Bound fixture texture
coord
Lookup coordinate
lod
Mip level; zero is full resolution

Return value

A vec4 from a 2D lookup using coordinates divided by the projection component and the explicit mip level.

Live example

Edit the code and the preview updates as you type.

What texture2DProjLod does

Combines projected coordinates with an explicit mip level in a vertex shader.

Read the preview

The vertex call uses vec3(uv,1.0), so projection currently leaves UV unchanged before the explicit LOD lookup. Change 1.0 to 2.0 and the interpolated corner colors come from the lower-left quarter of the texture.

Core call

texture2DProjLod(u_texture,vec3(uv,1.0),u_parameter*7.0).rgb;

Requires mipmaps; LOD is not a blur radius. This example executes in the vertex stage.

Experiment

In the Vertex source, set u_parameter*7.0 to 7.0. This chooses a very coarse mip at the vertices, so the quad becomes a blend of coarse samples rather than displaying sharp lettering.

Specification

GLSL ES 1.00 built-in functions, chapter 8

Related functions