From the GLSL documentation (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/length.xhtml), the length function "calculate the length of a vector".
But I don't get it, what does "length" mean here ?
For instance:
length(.5); // returns .5
length(1.); // returns 1.
So how and why are you supposed to use this function?
See The OpenGL ES Shading Language
8 Built-in Functions, page 63
When the built-in functions are specified below, where the input arguments (and corresponding output) can be
float,vec2,vec3, orvec4, genType is used as the argument.
8.4 Geometric Functions, page 68
float length (genType x)Returns the length of vector x, i.e.,
This means the result of length(.5) is:
sqrt(0.5 * 0.5) = 0.5
and the result of length(1.) is
sqrt(1.0 * 1.0) = 1.0
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