【Unity3d Shader】内置函数

Unity Shader 内置函数  Intrinsic Functions (DirectX HLSL)

官网链接

NameSyntaxDescription描述
absabs(x)Absolute value (per component). 计算输入值的绝对值。
acosacos(x)Returns the arccosine of each component of x. 返回输入值反余弦值。
allall(x)Test if all components of x are nonzero. 测试非0值。
anyany(x)Test if any component of x is nonzero. 测试输入值中的任何非零值。
asfloatasfloat(x)Convert the input type to a float. 
asinasin(x)Returns the arcsine of each component of x. 返回输入值的反正弦值。
asintasint(x)Convert the input type to an integer. 
asuintasuint(x)Convert the input type to an unsigned integer. 
atanatan(x)Returns the arctangent of x. 返回输入值的反正切值。
atan2atan2(y, x)Returns the arctangent of of two values (x,y). 返回y/x的反正切值。
ceilceil(x)Returns the smallest integer which is greater than or equal to x. 返回大于或等于输入值的最小整数。
clampclamp(x, min, max)Clamps x to the range [min, max]. 把输入值限制在[min, max]范围内。
clipclip(x)Discards the current pixel, if any component of x is less than zero. 如果输入向量中的任何元素小于0,则丢弃当前像素。
coscos(x)Returns the cosine of x. 返回输入值的余弦。
coshcosh(x)Returns the hyperbolic cosine of x. 返回输入值的双曲余弦。
crosscross(x, y)Returns the cross product of two 3D vectors. 返回两个3D向量的叉积。
ddxddx(x)Returns the partial derivative of x with respect to the screen-space x-coordinate. 返回关于屏幕坐标x轴的偏导数。
ddyddy(x)Returns the partial derivative of x with respect to the screen-space y-coordinate. 返回关于屏幕坐标y轴的偏导数。
degreesdegrees(x)Converts x from radians to degrees. 弧度到角度的转换
determinantdeterminant(m)Returns the determinant of the square matrix m. 返回输入矩阵的值。
distancedistance(x, y)Returns the distance between two points. 返回两个输入点间的距离。
dotdot(x, y)Returns the dot product of two vectors. 返回两个向量的点积。
expexp(x)Returns the base-e exponent. 返回以e为底数,输入值为指数的指数函数值。
exp2exp2(x)Base 2 exponent (per component). 返回以2为底数,输入值为指数的指数函数值。
faceforwardfaceforward(n, i, ng)Returns -n * sign(•(i, ng)). 检测多边形是否位于正面。
floorfloor(x)Returns the greatest integer which is less than or equal to x. 返回小于等于x的最大整数。
fmodfmod(x, y)Returns the floating point remainder of x/y. 返回a / b的浮点余数。
fracfrac(x)Returns the fractional part of x. 返回输入值的小数部分。
frexpfrexp(x, exp)Returns the mantissa and exponent of x. 返回输入值的尾数和指数
fwidthfwidth(x)Returns abs(ddx(x)) + abs(ddy(x)) 返回 abs ( ddx (x) + abs ( ddy(x))。
isfiniteisfinite(x)Returns true if x is finite, false otherwise. 如果输入值为有限值则返回true,否则返回false。
isinfisinf(x)Returns true if x is +INF or -INF, false otherwise. 如何输入值为无限的则返回true。
isnanisnan(x)Returns true if x is NAN or QNAN, false otherwise. 如果输入值为NAN或QNAN则返回true。
ldexpldexp(x, exp)Returns x * 2exp frexp的逆运算,返回 x * 2 ^ exp。
lengthlength(v)Returns the length of the vector v. 
lerplerp(x, y, s)Returns x + s(y - x). 对输入值进行插值计算。
litlit(n • l, n • h, m)Returns a lighting vector (ambient, diffuse, specular, 1) 返回光照向量(环境光,漫反射光,镜面高光,1)。
loglog(x)Returns the base-e logarithm of x. 返回以e为底的对数。
log10log10(x)Returns the base-10 logarithm of x. 返回以10为底的对数。
log2log2(x)Returns the base-2 logarithm of x. 返回以2为底的对数。
maxmax(x, y)Selects the greater of x and y. 返回两个输入值中较大的一个。
minmin(x, y)Selects the lesser of x and y. 返回两个输入值中较小的一个。
modfmodf(x, out ip)Splits the value x into fractional and integer parts. 把输入值分解为整数和小数部分。
mulmul(x, y)Performs matrix multiplication using x and y. 返回输入矩阵相乘的积。
noisenoise(x)Generates a random value using the Perlin-noise algorithm. 
normalizenormalize(x)Returns a normalized vector. 返回规范化的向量,定义为 x / length(x)。
powpow(x, y)Returns xy. 返回输入值的指定次幂。
radiansradians(x)Converts x from degrees to radians. 角度到弧度的转换。
reflectreflect(i, n)Returns a reflection vector. 返回入射光线i对表面法线n的反射光线。
refractrefract(i, n, R)Returns the refraction vector. 返回在入射光线i,表面法线n,折射率为eta下的折射光线v。
roundround(x)Rounds x to the nearest integer 返回最接近于输入值的整数。
rsqrtrsqrt(x)Returns 1 / sqrt(x) 返回输入值平方根的倒数。
saturatesaturate(x)Clamps x to the range [0, 1] 把输入值限制到[0, 1]之间。
signsign(x)Computes the sign of x. 计算输入值的符号。
sinsin(x)Returns the sine of x 计算输入值的正弦值。
sincossincos(x, out s, out c)Returns the sine and cosine of x. 返回输入值的正弦和余弦值。
sinhsinh(x)Returns the hyperbolic sine of x 返回x的双曲正弦。
smoothstepsmoothstep(min, max, x)Returns a smooth Hermite interpolation between 0 and 1. 返回一个在输入值之间平稳变化的插值。
sqrtsqrt(x)Square root (per component) 返回输入值的平方根。
stepstep(a, x)Returns (x >= a) ? 1 : 0 返回(x >= a)? 1 : 0。
tantan(x)Returns the tangent of x 返回输入值的正切值。
tanhtanh(x)Returns the hyperbolic tangent of x 
tex1Dtex1D(s, t)1D texture lookup. 1D纹理查询。
tex1Dbiastex1Dbias(s, t)1D texture lookup with bias. 
tex1Dgradtex1Dgrad(s, t, ddx, ddy)1D texture lookup with a gradient. 
tex1Dlodtex1Dlod(s, t)1D texture lookup with LOD. 
tex1Dprojtex1Dproj(s, t)1D texture lookup with projective divide. 
tex2Dtex2D(s, t)2D texture lookup. 2D纹理查询。
tex2Dbiastex2Dbias(s, t)2D texture lookup with bias. 
tex2Dgradtex2Dgrad(s, t, ddx, ddy)2D texture lookup with a gradient. 
tex2Dlodtex2Dlod(s, t)2D texture lookup with LOD. 
tex2Dprojtex2Dproj(s, t)2D texture lookup with projective divide. 
tex3Dtex3D(s, t)3D texture lookup. 3D纹理查询。
tex3Dbiastex3Dbias(s, t)3D texture lookup with bias. 
tex3Dgradtex3Dgrad(s, t, ddx, ddy)3D texture lookup with a gradient. 
tex3Dlodtex3Dlod(s, t)3D texture lookup with LOD. 
tex3Dprojtex3Dproj(s, t)3D texture lookup with projective divide. 
texCUBEtexCUBE(s, t)Cube texture lookup. 立方纹理查询。
texCUBEbiastexCUBEbias(s, t)Cube texture lookup with bias. 
texCUBEgradtexCUBEgrad(s, t, ddx, ddy)Cube texture lookup with a gradient. 
texCUBElodtex3Dlod(s, t)Cube texture lookup with LOD. 
texCUBEprojtexCUBEproj(s, t)Cube texture lookup with projective divide. 
transposetranspose(m)Returns the transpose of the matrix m. 返回输入矩阵的转置。
trunctrunc(x)Truncates floating-point value(s) to integer value(s) 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值