GLSL built-in function

textureCubeLod()

Samples a cube map at an explicit mip level in the vertex stage.

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

Syntax

vec4 textureCubeLod(samplerCube sampler, vec3 direction, float lod)

Parameters

sampler
Bound fixture texture
direction
Input declared in the signature; match its type and dimensions
lod
Mip level; zero is full resolution

Return value

A vec4 from the cube map at the given direction and explicit mip level, evaluated in the vertex stage here.

Live example

Edit the code and the preview updates as you type.

What textureCubeLod does

Samples a cube map at an explicit mip level in the vertex stage.

Read the preview

textureCubeLod evaluates normalize(vec3(x,y,0.7)) at vertices, not at every fragment. Change 0.7 to 2.0 in the Vertex tab so all corner samples select +Z instead of side faces.

Core call

textureCubeLod(u_cube,normalize(vec3(x,y,0.7)),u_parameter*7.0).rgb;

Vertex-sampled colors are interpolated and are not identical to per-fragment lookup.

Experiment

Set the Vertex call's u_parameter*7.0 to 6.0. It reads a coarse cube-map mip and interpolates the corner colors; face lettering will not be reconstructed between vertices.

Specification

GLSL ES 1.00 built-in functions, chapter 8

Related functions