I'm a bit surprised I don't know this already, but it never hurts to admit you're still learning :)
In GLSL there are min
and max
functions that that, according to their documentation:
return the lesser/greater of two values
But how is that determined when the values are vectors? Obviously (1, 1)
would be less than (2, 2)
, but what is the min or max of (1, 3)
and (4, -2)
? Where is that logic formally described?
Quoting from the first source that I could find (PDF), at the top of §8.3 Common Functions, page 132:
These all operate component-wise. The description is per component.
Nearly all the functions that operator on vectors but really only make sense for a scalar operate component-wise. (This includes abs
, sign
, floor
, trunc
, round
, roundEven
, ceil
, fract
, mod
, modf
, min
, max
, clamp
, mix
, step
, smoothstep
, and a whole lot more.)
So, for example, the min of (1, 3)
and (4, -2)
is (1, -2)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With