[Unity3d Shader] built-in function

Unity Shader built-in functions Intrinsic Functions (DirectX HLSL)

Official website link

Name Syntax Description describe
abs abs(x) Absolute value (per component).  Calculates the absolute value of the input value.
acos acos(x) Returns the arccosine of each component of x.  Returns the arccosine of the input value.
all all(x) Test if all components of x are nonzero.  Test for non-zero values.
any any(x) Test if any component of x is nonzero.  Tests for any non-zero value in the input value.
asfloat asfloat(x) Convert the input type to a float.  
asin asin(x) Returns the arcsine of each component of x.  Returns the arcsine of the input value.
asint asint(x) Convert the input type to an integer.  
you lived you lived(x) Convert the input type to an unsigned integer.  
for the purpose time(x) Returns the arctangent of x.  Returns the arctangent of the input value.
atan2 atan2(y, x) Returns the arctangent of of two values (x,y).  Returns the arctangent of y/x.
ceil ceil(x) Returns the smallest integer which is greater than or equal to x.  Returns the smallest integer greater than or equal to the input value.
clamp clamp(x, min, max) Clamps x to the range [min, max].  Limit the input value to the range [min, max].
clip clip(x) Discards the current pixel, if any component of x is less than zero.  If any element in the input vector is less than 0, the current pixel is discarded.
cos cos(x) Returns the cosine of x.  Returns the cosine of the input value.
cosh cosh(x) Returns the hyperbolic cosine of x.  Returns the hyperbolic cosine of the input value.
cross cross(x, y) Returns the cross product of two 3D vectors.  Returns the cross product of two 3D vectors.
ddx ddx(x) Returns the partial derivative of x with respect to the screen-space x-coordinate.  Returns the partial derivative with respect to the screen coordinate x-axis.
yes d(x) Returns the partial derivative of x with respect to the screen-space y-coordinate.  Returns the partial derivative with respect to the screen coordinate y-axis.
degrees degrees(x) Converts x from radians to degrees.  Radian to Angle Conversion
determinant determinant(m) Returns the determinant of the square matrix m.  Returns the values ​​of the input matrix.
distance distance(x, y) Returns the distance between two points.  Returns the distance between two input points.
dot dot(x, y) Returns the dot product of two vectors.  Returns the dot product of two vectors.
exp exp(x) Returns the base-e exponent.  Returns the value of the exponential function with the base e and the input value as the exponent.
exp2 exp2(x) Base 2 exponent (per component).  返回以2为底数,输入值为指数的指数函数值。
faceforward faceforward(n, i, ng) Returns -n * sign(•(i, ng)).  检测多边形是否位于正面。
floor floor(x) Returns the greatest integer which is less than or equal to x.  返回小于等于x的最大整数。
fmod fmod(x, y) Returns the floating point remainder of x/y.  返回a / b的浮点余数。
frac frac(x) Returns the fractional part of x.  返回输入值的小数部分。
frexp frexp(x, exp) Returns the mantissa and exponent of x.  返回输入值的尾数和指数
fwidth fwidth(x) Returns abs(ddx(x)) + abs(ddy(x))  返回 abs ( ddx (x) + abs ( ddy(x))。
isfinite isfinite(x) Returns true if x is finite, false otherwise.  如果输入值为有限值则返回true,否则返回false。
isinf isinf(x) Returns true if x is +INF or -INF, false otherwise.  如何输入值为无限的则返回true。
isnan isnan(x) Returns true if x is NAN or QNAN, false otherwise.  如果输入值为NAN或QNAN则返回true。
ldexp ldexp(x, exp) Returns x * 2exp  frexp的逆运算,返回 x * 2 ^ exp。
length length(v) Returns the length of the vector v.  
lerp lerp(x, y, s) Returns x + s(y - x).  对输入值进行插值计算。
lit lit(n • l, n • h, m) Returns a lighting vector (ambient, diffuse, specular, 1)  返回光照向量(环境光,漫反射光,镜面高光,1)。
log log(x) Returns the base-e logarithm of x.  返回以e为底的对数。
log10 log10(x) Returns the base-10 logarithm of x.  返回以10为底的对数。
log2 log2(x) Returns the base-2 logarithm of x.  返回以2为底的对数。
max max(x, y) Selects the greater of x and y.  返回两个输入值中较大的一个。
min min(x, y) Selects the lesser of x and y.  返回两个输入值中较小的一个。
modf modf(x, out ip) Splits the value x into fractional and integer parts.  把输入值分解为整数和小数部分。
mul mul(x, y) Performs matrix multiplication using x and y.  返回输入矩阵相乘的积。
noise noise(x) Generates a random value using the Perlin-noise algorithm.  
normalize normalize(x) Returns a normalized vector.  返回规范化的向量,定义为 x / length(x)。
pow pow(x, y) Returns xy.  返回输入值的指定次幂。
radians radians(x) Converts x from degrees to radians.  角度到弧度的转换。
reflect reflect(i, n) Returns a reflection vector.  返回入射光线i对表面法线n的反射光线。
refract refract(i, n, R) Returns the refraction vector.  返回在入射光线i,表面法线n,折射率为eta下的折射光线v。
round round(x) Rounds x to the nearest integer  返回最接近于输入值的整数。
rsqrt rsqrt(x) Returns 1 / sqrt(x)  返回输入值平方根的倒数。
saturate saturate(x) Clamps x to the range [0, 1]  把输入值限制到[0, 1]之间。
sign sign(x) Computes the sign of x.  计算输入值的符号。
sin sin(x) Returns the sine of x  计算输入值的正弦值。
sincos sincos(x, out s, out c) Returns the sine and cosine of x.  返回输入值的正弦和余弦值。
sinh sinh(x) Returns the hyperbolic sine of x  返回x的双曲正弦。
smoothstep smoothstep(min, max, x) Returns a smooth Hermite interpolation between 0 and 1.  返回一个在输入值之间平稳变化的插值。
sqrt sqrt(x) Square root (per component)  返回输入值的平方根。
step step(a, x) Returns (x >= a) ? 1 : 0  返回(x >= a)? 1 : 0。
tan tan(x) Returns the tangent of x  返回输入值的正切值。
tanh tanh(x) Returns the hyperbolic tangent of x  
tex1D tex1D(s, t) 1D texture lookup.  1D纹理查询。
tex1Dbias tex1Dbias(s, t) 1D texture lookup with bias.  
tex1Dgrad tex1Dgrad(s, t, ddx, ddy) 1D texture lookup with a gradient.  
tex1Dlod tex1Dlod(s, t) 1D texture lookup with LOD.  
tex1Dproj tex1Dproj(s, t) 1D texture lookup with projective divide.  
tex2D tex2D(s, t) 2D texture lookup.  2D纹理查询。
tex2Dbias tex2Dbias(s, t) 2D texture lookup with bias.  
tex2Dgrad tex2Dgrad(s, t, ddx, ddy) 2D texture lookup with a gradient.  
tex2Dlod tex2Dlod(s, t) 2D texture lookup with LOD.  
tex2Dproj tex2Dproj(s, t) 2D texture lookup with projective divide.  
tex3D tex3D(s, t) 3D texture lookup.  3D纹理查询。
tex3Dbias tex3Dbias(s, t) 3D texture lookup with bias.  
tex3Dgrad tex3Dgrad(s, t, ddx, ddy) 3D texture lookup with a gradient.  
tex3Dlod tex3Dlod(s, t) 3D texture lookup with LOD.  
tex3Dproj tex3Dproj(s, t) 3D texture lookup with projective divide.  
texCUBE texCUBE(s, t) Cube texture lookup.  立方纹理查询。
texCUBEbias texCUBEbias(s, t) Cube texture lookup with bias.  
texCUBEgrad texCUBEgrad(s, t, ddx, ddy) Cube texture lookup with a gradient.  
texCUBElod tex3Dlod(s, t) Cube texture lookup with LOD.  
texCUBEproj texCUBEproj(s, t) Cube texture lookup with projective divide.  
transpose transpose(m) Returns the transpose of the matrix m.  返回输入矩阵的转置。
trunc trunc(x) Truncates floating-point value(s) to integer value(s)  

 

Guess you like

Origin blog.csdn.net/PangNanGua/article/details/103139386