GLSL built-in function

lessThan()

Component-wise less-than comparison returning a boolean vector.

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

Syntax

bvec2 lessThan(vec2 x, vec2 y)
bvec3 lessThan(vec3 x, vec3 y)
bvec4 lessThan(vec4 x, vec4 y)
bvec2 lessThan(ivec2 x, ivec2 y)
bvec3 lessThan(ivec3 x, ivec3 y)
bvec4 lessThan(ivec4 x, ivec4 y)

Parameters

x
Input value or left-hand vector
y
Right-hand vector or comparison value

Return value

A boolean vector containing true where each component of x is strictly less than its counterpart in y.

Live example

Edit the code and the preview updates as you type.

What lessThan does

Component-wise less-than comparison returning a boolean vector.

Read the preview

Selecting .x from lessThan(vec2(x,y),vec2(0.0)) marks the left half. Try a bound of vec2(-0.5) to restrict the selected region to the leftmost quarter.

Core call

float(lessThan(vec2(x,y),vec2(0.0)).x);

A bvec is not a scalar condition; reduce it with any or all.

Experiment

Change the final .x to .y while leaving the bound at zero. The comparison then paints the lower half because y, rather than x, must be negative.

Specification

GLSL ES 1.00 built-in functions, chapter 8

Related functions