GLSL built-in function
lessThanEqual()
Component-wise less-than-or-equal comparison, including the boundary.
Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Fragment
Syntax
bvec2 lessThanEqual(vec2 x, vec2 y)
bvec3 lessThanEqual(vec3 x, vec3 y)
bvec4 lessThanEqual(vec4 x, vec4 y)
bvec2 lessThanEqual(ivec2 x, ivec2 y)
bvec3 lessThanEqual(ivec3 x, ivec3 y)
bvec4 lessThanEqual(ivec4 x, ivec4 y)Parameters
- x
- Input value or left-hand vector
- y
- Right-hand vector or comparison value
Return value
A boolean vector that includes equality: each component is true when x ≤ y.
Live example
Edit the code and the preview updates as you type.
What lessThanEqual does
Component-wise less-than-or-equal comparison, including the boundary.
Read the preview
lessThanEqual(vec2(x,y),vec2(0.0)).x selects x ≤ 0. Raise the comparison vector to vec2(0.5) and the true region expands to three quarters of the width.
Core call
float(lessThanEqual(vec2(x,y),vec2(0.0)).x);
Floating-point arithmetic can move a computed value across the boundary.
Experiment
Compare vec2(0.0) against vec2(0.0) in the lessThanEqual call. The whole background becomes true, making inclusion of the equality case visible without needing a pixel exactly at x = 0.