|
fennec
|
The Geometric Functions defined in the OpenGL 4.6 Shading Language Specification.
| Syntax | Description | ||||||
|---|---|---|---|---|---|---|---|
float dot(genFType x, genFType y) double dot(genDType x, genDType x) |
Returns the dot product of \(x\) and \(y\), i.e., \(x_0 \cdot y_0 + x_1 \cdot y_1 + \ldots\).
we can represent this in linear algebra as the following, then \(\text{dot}(X, Y)=X \cdot Y^T\)
| ||||||
float length2(genFType x) double length2(genDType x) |
Returns the squared length of vector \(x\), i.e., \(x_0^2 + x_1^2 + \ldots\).
we can represent this in linear algebra as the following, then \(\text{length2}(X)=X \cdot X^T\)
| ||||||
float length(genFType x) double length(genDType x) |
Returns the length of vector \(x\), i.e., \(\sqrt{x_0^2 + x_1^2 + \ldots}\).
we can represent this in linear algebra as the following, then, \(\text{length}(X)=\left|\left|X\right|\right|\)
| ||||||
float distance(genFType x, genFType y) double distance(genDType x, genDType x) |
Returns the length of vector \(x\), i.e., \(\sqrt{x_0^2 + x_1^2 + \ldots}\).
we can represent this in linear algebra as the following, then \(\text{distance}(X, Y)=\left|\left|Y-X\right|\right|\)
| ||||||
float normalize(genFType x) double normalize(genDType x) |
Returns a vector in the same direction as \(x\), but with a length of \(1\), i.e.
we can represent this in linear algebra as the following, then, \(\text{length}(X)=\frac{X}{\left|\left|X\right|\right|}\)
| ||||||
vec3 cross(vec3 x, vec3 y) dvec3 cross(dvec3 x, dvec3 x) |
Returns the cross product of \(x\) and \(y\), i.e., \(\left({x_1 \cdot y_2 - y_1 \cdot x_2, x_2 \cdot y_0 - y_2 \cdot x_0, x_0 \cdot y_1 - y_0 \cdot x_1}\right)\).
we can represent this in linear algebra as the following, then \(\text{cross}(X, Y)=X \times Y\)
| ||||||
genFType faceforward(genFType N, genFType I, genFType Nref) genDType faceforward(genDType N, genDType I, genDType Nref) |
If \(\text{dot}(Nref, I)<0\) return \(N\), otherwise return \(-N\).
| ||||||
genFType reflect(genFType I, genFType N) genDType reflect(genDType I, genDType N) |
For the incident vector \(I\) and surface orientation \(N\), returns the reflection direction.
We can express this as,
| ||||||
genFType refract(genFType N, genFType I, float eta) genDType refract(genDType N, genDType I, double eta) |
For the incident vector \(I\) and surface normal \(N\), and the ratio of indices of refraction \(eta\), return the refraction vector.
The result is computed by the refraction equation,
|