方法/函数/库
. | . |
---|---|
saturate | Saturate is a function that clamps it’s input between 0 and 1. |
normalize | float normalize(float x) vec2 normalize(vec2 x) vec3 normalize(vec3 x) vec4 normalize(vec4 x) normalize() returns a vector with the same direction as its parameter, x, but with length 1. |
dot | 点乘。 float dot(float x, float y) float dot(vec2 x, vec2 y) float dot(vec3 x, vec3 y) float dot(vec4 x, vec4 y) dot() returns the dot product of two vectors, x and y. i.e., x[0]⋅y[0]+x[1]⋅y[1]+… If x and y are the same the square root of the dot product is equivalent to the length of the vector. The input parameters can be floating scalars or float vectors. In case of floating scalars the dot function is trivial and returns the product of x and y. |
pow | pow(x, y) x的y次幂 |
rcp | rcp(x) = x的倒数(1/x) 借此来优化除法运算 shader低级优化 |
Unity Built-in shader variables
Tips
世界空间 模型空间 观察空间 投影空间
UNITY_MATRIX_MVP 模型空间–M–>世界空间–V–>观察空间–P–>裁剪空间