HLSL中的内置函数

HLSL中的内置函数

以下是HLSL中的内置函数,摘自网络:
Name(函数名) Syntax(语法) Description(描述)
abs abs(x) 返回x的绝对值。对x的每个元素都会独立计算一次。Absolute value (per component).
acos acos(x) 返回x的反余弦值。对x的每个元素都会独立计算一次。Returns the arccosine of each component of x.
all all(x) 检测x的所有元数的值是否为0.Test if all components of x are nonzero.
any any(x) 检测x是否有某个元数的值为0.Test if any component of x is nonzero.
asfloat asfloat(x) 将x转换为float类型。Convert the input type to a float. 
asin asin(x) 返回x的反正弦值。对x的每个元素都会独立计算一次。
asint asint(x) 将x转换为int类型。Convert the input type to an integer.
asuint asuint(x) 将x转换为uint类型。
atan atan(x) 返回x的反正切值。
atan2 atan2(y, x) 返回y、x的反正切值。
ceil ceil(x) 返回大于或等于x的最小整数。
clamp clamp(x, min, max) 将x截取在[min, max]范围内。
clip clip(x) 如果x中存在值小于0的参数,则丢弃当前像素。
cos cos(x) 返回x的余弦值。
cosh cosh(x) 返回x的双曲余弦值。
cross cross(x, y) 返回x、y的叉积。 
D3DCOLORtoUBYTE4 D3DCOLORtoUBYTE4(x) 混合和缩放4D向量x用于补偿一些对UBYTE4支持的硬件。Swizzles and scales components of the 4D vector x to compensate for the lack of UBYTE4 support in some hardware. 
ddx ddx(x) 返回关于屏幕坐标x轴的偏导数。 
ddy ddy(x) 返回关于屏幕坐标y轴的偏导数。
degrees degrees(x) 将x(弧度)转换到角度。
determinant determinant(m) 返回的正方形矩阵m的行列式。
distance distance(x, y) 返回x、y之间的距离。
dot dot(x, y) 返回x、y的点积。
exp exp(x) 返回以e为底数,x为指数的指数函数值。
exp2 exp2(x) 返回以2为底数,x为指数的指数函数值。对x的每个字段都会计算一次。
faceforward faceforward(n, i, ng) 检测多边形是否位于正面。-n * sign(•(i, ng))。
floor floor(x) 返回小于等于x的最大整数。
fmod fmod(x, y) 返回x/y的浮点余数。
frac frac(x) 返回x的小数部分。
frexp frexp(x, exp) 返回x的尾数和指数。
fwidth fwidth(x) 返回 abs(ddx(x)) + abs(ddy(x)),
GetRenderTargetSampleCount GetRenderTargetSampleCount() 返回渲染目标采样器的个数。Returns the number of render-target samples. 
GetRenderTargetSamplePosition GetRenderTargetSamplePosition(x) 返回关于给定采样器的一个采样点(x,y)。Returns a sample position (x,y) for a given sample index. 
isfinite isfinite(x) 如果x为有限值则返回true,否则返回false。
isinf isinf(x) 如果x为无限值则返回true,否则返回false。
isnan isnan(x) 如果x为NAN或QNAN则返回true,否则返回false。
ldexp ldexp(x, exp) frexp的逆运算,返回 x * 2 ^ exp。
length length(v) 返回v向量的长度。
lerp lerp(x, y, s) 对x、y进行插值计算。Returns x + s(y - x)。
lit lit(n • l, n • h, m) 返回光照向量(环境光,漫反射光,镜面高光,1)。
log log(x) 返回以e为底的对数。
log10 log10(x) 返回以10为底的对数。
log2 log2(x) 返回以2为底的对数。
max max(x, y) 返回x、y中较大值。
min min(x, y) 返回x、y中较小值。
modf modf(x, out ip) 把x分割为整数和小数部分。
mul mul(x, y) 返回x、y矩阵相乘的积。
noise noise(x) Generates a random value using the Perlin-noise algorithm. 
normalize normalize(x) 返回单位化向量,定义为 x / length(x)。
pow pow(x, y) 返回x^y。
radians radians(x) 将x(角度)转换到弧度。
reflect reflect(i, n) 返回入射光线i对表面法线n的反射光线。
refract refract(i, n, R) 返回在入射光线i,表面法线n,折射率为R下的折射光线。
round round(x) 返回最接近x的整数。
rsqrt rsqrt(x) 返回x平方根的倒数。 1 / sqrt(x) 。
saturate saturate(x) 把x截取在[0, 1]之间。
sign sign(x) 返回x的符号。
sin sin(x) 返回x的正弦值。
sincos sincos(x, out s, out c) 返回x的正弦值和余弦值。
sinh sinh(x) 返回x的双曲正弦值。
smoothstep smoothstep(min, max, x) 如果x的范围是[min, max],则返回一个介于0和1之间的Hermite插值。
sqrt sqrt(x) 返回x的平方根,对x的每个字段都会计算一次。
step step(a, x) 返回 (x >= a) ? 1 : 0 。
tan tan(x) 返回x的正切值。
tanh tanh(x) 返回x的双曲正切值。
tex1D tex1D(s, t) 返回纹理s在t位置的颜色。1D texture lookup. 
tex1Dbias tex1Dbias(s, t) 使用bias返回纹理s在t位置的颜色。1D texture lookup with bias. 
tex1Dgrad tex1Dgrad(s, t, ddx, ddy) 1D texture lookup with a gradient. 
tex1Dlod tex1Dlod(s, t) 使用LOD返回纹理s在t位置的颜色。1D texture lookup with LOD. 
tex1Dproj tex1Dproj(s, t) 使用透视分离返回纹理s在t位置的颜色。1D texture lookup with projective divide. 
tex2D tex2D(s, t) 返回纹理s在t位置的颜色。
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. 
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) 返回m的转置矩阵。
trunc trunc(x) 将x的所有元素从浮点值截断到整数值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值