GLSL built-in function
greaterThan()
Component-wise greater-than comparison.
Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Fragment
Syntax
bvec2 greaterThan(vec2 x, vec2 y)
bvec3 greaterThan(vec3 x, vec3 y)
bvec4 greaterThan(vec4 x, vec4 y)
bvec2 greaterThan(ivec2 x, ivec2 y)
bvec3 greaterThan(ivec3 x, ivec3 y)
bvec4 greaterThan(ivec4 x, ivec4 y)Parameters
- x
- Input value or left-hand vector
- y
- Right-hand vector or comparison value
Return value
A boolean vector with true wherever x is strictly greater than y in the corresponding component.
Live example
Edit the code and the preview updates as you type.
What greaterThan does
Component-wise greater-than comparison.
Read the preview
The preview reads .x from greaterThan(vec2(x,y),vec2(0.0)), so only the right half is true. Set the bound to vec2(0.5) to move the division to x = 0.5.
Core call
float(greaterThan(vec2(x,y),vec2(0.0)).x);
Each boolean result corresponds to the matching input components.
Experiment
Keep the zero bound and change the selected component from .x to .y. The true region moves from the right half to the top half of the canvas.