HLSL中的内置函数

来源:互联网 发布:软件 会展 编辑:程序博客网 时间:2024/05/20 16:42

HLSL中的内置函数

以下是HLSL中的内置函数,摘自网络:
Name(函数名)Syntax(语法)Description(描述)absabs(x)返回x的绝对值。对x的每个元素都会独立计算一次。Absolute value (per component).acosacos(x)返回x的反余弦值。对x的每个元素都会独立计算一次。Returns the arccosine of each component of x.allall(x)检测x的所有元数的值是否为0.Test if all components of x are nonzero.anyany(x)检测x是否有某个元数的值为0.Test if any component of x is nonzero.asfloatasfloat(x)将x转换为float类型。Convert the input type to a float. asinasin(x)返回x的反正弦值。对x的每个元素都会独立计算一次。asintasint(x)将x转换为int类型。Convert the input type to an integer.asuintasuint(x)将x转换为uint类型。atanatan(x)返回x的反正切值。atan2atan2(y, x)返回y、x的反正切值。ceilceil(x)返回大于或等于x的最小整数。clampclamp(x, min, max)将x截取在[min, max]范围内。clipclip(x)如果x中存在值小于0的参数,则丢弃当前像素。coscos(x)返回x的余弦值。coshcosh(x)返回x的双曲余弦值。crosscross(x, y)返回x、y的叉积。 D3DCOLORtoUBYTE4D3DCOLORtoUBYTE4(x)混合和缩放4D向量x用于补偿一些对UBYTE4支持的硬件。Swizzles and scales components of the 4D vector x to compensate for the lack of UBYTE4 support in some hardware. ddxddx(x)返回关于屏幕坐标x轴的偏导数。 ddyddy(x)返回关于屏幕坐标y轴的偏导数。degreesdegrees(x)将x(弧度)转换到角度。determinantdeterminant(m)返回的正方形矩阵m的行列式。distancedistance(x, y)返回x、y之间的距离。dotdot(x, y)返回x、y的点积。expexp(x)返回以e为底数,x为指数的指数函数值。exp2exp2(x)返回以2为底数,x为指数的指数函数值。对x的每个字段都会计算一次。faceforwardfaceforward(n, i, ng)检测多边形是否位于正面。-n * sign(•(i, ng))。floorfloor(x)返回小于等于x的最大整数。fmodfmod(x, y)返回x/y的浮点余数。fracfrac(x)返回x的小数部分。frexpfrexp(x, exp)返回x的尾数和指数。fwidthfwidth(x)返回 abs(ddx(x)) + abs(ddy(x)),GetRenderTargetSampleCountGetRenderTargetSampleCount()返回渲染目标采样器的个数。Returns the number of render-target samples. GetRenderTargetSamplePositionGetRenderTargetSamplePosition(x)返回关于给定采样器的一个采样点(x,y)。Returns a sample position (x,y) for a given sample index. isfiniteisfinite(x)如果x为有限值则返回true,否则返回false。isinfisinf(x)如果x为无限值则返回true,否则返回false。isnanisnan(x)如果x为NAN或QNAN则返回true,否则返回false。ldexpldexp(x, exp)frexp的逆运算,返回 x * 2 ^ exp。lengthlength(v)返回v向量的长度。lerplerp(x, y, s)对x、y进行插值计算。Returns x + s(y - x)。litlit(n • l, n • h, m)返回光照向量(环境光,漫反射光,镜面高光,1)。loglog(x)返回以e为底的对数。log10log10(x)返回以10为底的对数。log2log2(x)返回以2为底的对数。maxmax(x, y)返回x、y中较大值。minmin(x, y)返回x、y中较小值。modfmodf(x, out ip)把x分割为整数和小数部分。mulmul(x, y)返回x、y矩阵相乘的积。noisenoise(x)Generates a random value using the Perlin-noise algorithm. normalizenormalize(x)返回单位化向量,定义为 x / length(x)。powpow(x, y)返回x^y。radiansradians(x)将x(角度)转换到弧度。reflectreflect(i, n)返回入射光线i对表面法线n的反射光线。refractrefract(i, n, R)返回在入射光线i,表面法线n,折射率为R下的折射光线。roundround(x)返回最接近x的整数。rsqrtrsqrt(x)返回x平方根的倒数。 1 / sqrt(x) 。saturatesaturate(x)把x截取在[0, 1]之间。signsign(x)返回x的符号。sinsin(x)返回x的正弦值。sincossincos(x, out s, out c)返回x的正弦值和余弦值。sinhsinh(x)返回x的双曲正弦值。smoothstepsmoothstep(min, max, x)如果x的范围是[min, max],则返回一个介于0和1之间的Hermite插值。sqrtsqrt(x)返回x的平方根,对x的每个字段都会计算一次。stepstep(a, x)返回 (x >= a) ? 1 : 0 。tantan(x)返回x的正切值。tanhtanh(x)返回x的双曲正切值。tex1Dtex1D(s, t)返回纹理s在t位置的颜色。1D texture lookup. tex1Dbiastex1Dbias(s, t)使用bias返回纹理s在t位置的颜色。1D texture lookup with bias. tex1Dgradtex1Dgrad(s, t, ddx, ddy)1D texture lookup with a gradient. tex1Dlodtex1Dlod(s, t)使用LOD返回纹理s在t位置的颜色。1D texture lookup with LOD. tex1Dprojtex1Dproj(s, t)使用透视分离返回纹理s在t位置的颜色。1D texture lookup with projective divide. tex2Dtex2D(s, t)返回纹理s在t位置的颜色。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. 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)返回m的转置矩阵。trunctrunc(x)将x的所有元素从浮点值截断到整数值。
0 0