GLSL built-in function
equal()
Tests exact equality independently for each vector component.
Demo version: GLSL ES 1.00 / WebGL 1Demo stage: Fragment
Syntax
bvec2 equal(vec2 x, vec2 y)
bvec3 equal(vec3 x, vec3 y)
bvec4 equal(vec4 x, vec4 y)
bvec2 equal(ivec2 x, ivec2 y)
bvec3 equal(ivec3 x, ivec3 y)
bvec4 equal(ivec4 x, ivec4 y)
bvec2 equal(bvec2 x, bvec2 y)
bvec3 equal(bvec3 x, bvec3 y)
bvec4 equal(bvec4 x, bvec4 y)Parameters
- x
- Input value or left-hand vector
- y
- Right-hand vector or comparison value
Return value
A boolean vector whose components are true exactly where the corresponding x and y components are equal.
Live example
Edit the code and the preview updates as you type.
What equal does
Tests exact equality independently for each vector component.
Read the preview
Only the strip with floor(x*4.0) == 0 selects the orange color. Compare against ivec2(1) instead of ivec2(0) to move that strip to x in [0.25, 0.5).
Core call
float(equal(ivec2(int(floor(x*4.0)),0),ivec2(0)).x);
Use a tolerance for computed floating-point values rather than exact equality.
Experiment
Change the final .x after equal(...) to .y. Both second components are zero in the original call, so the entire background now shows the true result.