日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

常用shader固有函数

發布時間:2023/12/13 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 常用shader固有函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉載自http://www.cppblog.com/lai3d/archive/2008/10/23/64889.html

Intrinsic Functions (DirectX HLSL)

The following table lists the intrinsic functions available in HLSL. Each function has a brief description, and a link to a reference page that has more detail about the input argument and return type.

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.
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).
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].
clipclip(x)Discards the current pixel, if any component of x is less than zero.
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.
D3DCOLORtoUBYTE4D3DCOLORtoUBYTE4(x)Swizzles and scales components of the 4D vector x to compensate for the lack of UBYTE4 support in some hardware.
ddxddx(x)Returns the partial derivative of x with respect to the screen-space x-coordinate.
ddyddy(x)Returns the partial derivative of x with respect to the screen-space y-coordinate.
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.
exp2exp2(x)Base 2 exponent (per component).
faceforwardfaceforward(n, i, ng)Returns -n * sign(?(i, ng)).
floorfloor(x)Returns the greatest integer which is less than or equal to x.
fmodfmod(x, y)Returns the floating point remainder of x/y.
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))
GetRenderTargetSampleCountGetRenderTargetSampleCount()Returns the number of render-target samples.
GetRenderTargetSamplePositionGetRenderTargetSamplePosition(x)Returns a sample position (x,y) for a given sample index.
isfiniteisfinite(x)Returns true if x is finite, false otherwise.
isinfisinf(x)Returns true if x is +INF or -INF, false otherwise.
isnanisnan(x)Returns true if x is NAN or QNAN, false otherwise.
ldexpldexp(x, exp)Returns x * 2exp
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)
loglog(x)Returns the base-e logarithm of x.
log10log10(x)Returns the base-10 logarithm of x.
log2log2(x)Returns the base-2 logarithm of x.
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.
powpow(x, y)Returns xy.
radiansradians(x)Converts x from degrees to radians.
reflectreflect(i, n)Returns a reflection vector.
refractrefract(i, n, R)Returns the refraction vector.
roundround(x)Rounds x to the nearest integer
rsqrtrsqrt(x)Returns 1 / sqrt(x)
saturatesaturate(x)Clamps x to the range [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
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
tantan(x)Returns the tangent of x
tanhtanh(x)Returns the hyperbolic tangent of x
tex1Dtex1D(s, t)1D texture lookup.
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.
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)Returns the transpose of the matrix m.
trunctrunc(x)Truncates floating-point value(s) to integer value(s)


?

表 3-1 HLSL內置函數

函數名?????????? ?用法

abs???????????????????????? 計算輸入值的絕對值。

acos??????????????????????? 返回輸入值反余弦值。

all?????????????????????????? 測試非0值。

any???????????????????????? 測試輸入值中的任何非零值。

asin???????????????????????? 返回輸入值的反正弦值。

atan??????????????????????? 返回輸入值的反正切值。

atan2?????????????????????? 返回y/x的反正切值。

ceil???????????????????????? 返回大于或等于輸入值的最小整數。

clamp????????????????????? 把輸入值限制在[min, max]范圍內。

clip???????????????????????? 如果輸入向量中的任何元素小于0,則丟棄當前像素。

cos???????????????????????? 返回輸入值的余弦。

cosh?????????????????????? 返回輸入值的雙曲余弦。

cross????????????????????? 返回兩個3D向量的叉積。

ddx???????????????????????? 返回關于屏幕坐標x軸的偏導數。

ddy???????????????????????? 返回關于屏幕坐標y軸的偏導數。

degrees?????????????????? 弧度到角度的轉換

determinant????????????? 返回輸入矩陣的值。

distance?????????????????? 返回兩個輸入點間的距離。

dot????????????????????????? 返回兩個向量的點積。

exp???????????????????????? 返回以e為底數,輸入值為指數的指數函數值。

exp2?????????????????????? 返回以2為底數,輸入值為指數的指數函數值。

faceforward???????????? 檢測多邊形是否位于正面。

floor?????????????????????? 返回小于等于x的最大整數。

fmod?????????????????????? 返回a / b的浮點余數。

frac??????????????????????? 返回輸入值的小數部分。

frexp?????????????????????? 返回輸入值的尾數和指數

fwidth???????????????????? 返回 abs ( ddx (x) + abs ( ddy(x))。

isfinite???????????????????? 如果輸入值為有限值則返回true,否則返回false。

isinf??????????????????????? 如何輸入值為無限的則返回true。

isnan?????????????????????? 如果輸入值為NAN或QNAN則返回true。

ldexp?????????????????????? frexp的逆運算,返回 x * 2 ^ exp。

len / lenth??????????????? 返回輸入向量的長度。

lerp???????????????????????? 對輸入值進行插值計算。

lit??????????????????????????? 返回光照向量(環境光,漫反射光,鏡面高光,1)。

log????????????????????????? 返回以e為底的對數。

log10????????????????????? 返回以10為底的對數。

log2??????????????????????? 返回以2為底的對數。

max??????????????????????? 返回兩個輸入值中較大的一個。

min???????????????????????? 返回兩個輸入值中較小的一個。

modf?????????????????????? 把輸入值分解為整數和小數部分。

mul???????????????????????? 返回輸入矩陣相乘的積。

normalize???????????????? 返回規范化的向量,定義為 x / length(x)。

pow??????????????????????? 返回輸入值的指定次冪。

radians??????????????????? 角度到弧度的轉換。

reflect???????????????????? 返回入射光線i對表面法線n的反射光線。

refract???????????????????? 返回在入射光線i,表面法線n,折射率為eta下的折射光線v。

round????????????????????? 返回最接近于輸入值的整數。

rsqrt?????????????????????? 返回輸入值平方根的倒數。

saturate?????????????????? 把輸入值限制到[0, 1]之間。

sign??????????????????????? 計算輸入值的符號。

sin????????????????????????? 計算輸入值的正弦值。

sincos???????????????????? 返回輸入值的正弦和余弦值。

sinh??????????????????????? 返回x的雙曲正弦。

smoothstep????????????? 返回一個在輸入值之間平穩變化的插值。

sqrt???????????????????????? 返回輸入值的平方根。

step??????????????????????? 返回(x >= a)? 1 : 0。

tan????????????????????????? 返回輸入值的正切值。

fanh??????????????????????? 返回輸入值的雙曲線切線。

transpose???????????????? 返回輸入矩陣的轉置。

tex1D*??????????????????? 1D紋理查詢。

tex2D*??????????????????? 2D紋理查詢。

tex3D*??????????????????? 3D紋理查詢。

texCUBE*??????????????? 立方紋理查詢。

總結

以上是生活随笔為你收集整理的常用shader固有函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。