CG 内置函数 和 HLSL 内置函数

CG与HLSL内置函数详解
本文详细介绍了CG和HLSL中的内置函数,包括数学运算、纹理操作、光线追踪等常用函数,帮助开发者更好地理解和使用这些函数进行图形渲染和着色语言编程。

CG 内置函数  英伟达官网链接:

  http://http.developer.nvidia.com/Cg/index_stdlib.html

abs
acos
all
any
asin
atan2
atan
bitCount
bitfieldExtract
bitfieldInsert
bitfieldReverse
ceil
clamp
clip
cosh
cos
cross
ddx
ddy
degrees
determinant
distance
dot
exp2
exp
faceforward
findLSB
findMSB
floatToIntBits
floatToRawIntBits
floor
fmod
frac
frexp
fwidth
intBitsToFloat
inverse
isfinite
isinf
isnan
ldexp
length
lerp
lit
log10
log2
log
max
min
modf
mul
normalize
pack
pow
radians
reflect
refract
round
rsqrt
saturate
sign
sincos
sinh
sin
smoothstep
sqrt
step
tanh
tan
tex1DARRAYbias
tex1DARRAYcmpbias
tex1DARRAYcmplod
tex1DARRAYfetch
tex1DARRAYlod
tex1DARRAY
tex1DARRAYproj
tex1DARRAYsize
tex1Dbias
tex1Dcmpbias
tex1Dcmplod
tex1Dfetch
tex1Dlod
tex1D
tex1Dproj
tex1Dsize
tex2DARRAYbias
tex2DARRAYfetch
tex2DARRAYlod
tex2DARRAY
tex2DARRAYproj
tex2DARRAYsize
tex2Dbias
tex2Dcmpbias
tex2Dcmplod
tex2Dfetch
tex2Dlod
tex2DMSARRAYfetch
tex2DMSARRAYsize
tex2DMSfetch
tex2DMSsize
tex2D
tex2Dproj
tex2Dsize
tex3Dbias
tex3Dfetch
tex3Dlod
tex3D
tex3Dproj
tex3Dsize
texBUF
texBUFsize
texCUBEARRAYbias
texCUBEARRAYlod
texCUBEARRAY
texCUBEARRAYsize
texCUBEbias
texCUBElod
texCUBE
texCUBEproj
texCUBEsize
texRBUF
texRBUFsize
texRECTbias
texRECTfetch
texRECTlod
texRECT
texRECTproj
texRECTsize
transpose
trunc
unpack

HLSL 内置函数:https://msdn.microsoft.com/en-us/library/ff471376(v=vs.85).aspx

Intrinsic Functions

 

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.

NameDescriptionMinimum shader model
abortTerminates the current draw or dispatch call being executed.4
absAbsolute value (per component).
acosReturns the arccosine of each component of x.
allTest if all components of x are nonzero.
AllMemoryBarrierBlocks execution of all threads in a group until all memory accesses have been completed.5
AllMemoryBarrierWithGroupSyncBlocks execution of all threads in a group until all memory accesses have been completed and all threads in the group have reached this call.5
anyTest if any component of x is nonzero.
asdoubleReinterprets a cast value into a double.5
asfloatConvert the input type to a float.4
asinReturns the arcsine of each component of x.
asintConvert the input type to an integer.4
asuintReinterprets the bit pattern of a 64-bit type to a uint.5
asuintConvert the input type to an unsigned integer.4
atanReturns the arctangent of x.
atan2Returns the arctangent of of two values (x,y).
ceilReturns the smallest integer which is greater than or equal to x.
CheckAccessFullyMappedDetermines whether all values from a Sample or Load operation accessed mapped tiles in a tiled resource.5
clampClamps x to the range [min, max].
clipDiscards the current pixel, if any component of x is less than zero.
cosReturns the cosine of x.
coshReturns the hyperbolic cosine of x.
countbitsCounts the number of bits (per component) in the input integer.5
crossReturns the cross product of two 3D vectors.
D3DCOLORtoUBYTE4Swizzles and scales components of the 4D vector xto compensate for the lack of UBYTE4 support in some hardware.
ddxReturns the partial derivative of x with respect to the screen-space x-coordinate.
ddx_coarseComputes a low precision partial derivative with respect to the screen-space x-coordinate.5
ddx_fineComputes a high precision partial derivative with respect to the screen-space x-coordinate.5
ddyReturns the partial derivative of x with respect to the screen-space y-coordinate.
ddy_coarseComputes a low precision partial derivative with respect to the screen-space y-coordinate.5
ddy_fineComputes a high precision partial derivative with respect to the screen-space y-coordinate.5
degreesConverts x from radians to degrees.
determinantReturns the determinant of the square matrix m.
DeviceMemoryBarrierBlocks execution of all threads in a group until all device memory accesses have been completed.5
DeviceMemoryBarrierWithGroupSyncBlocks execution of all threads in a group until all device memory accesses have been completed and all threads in the group have reached this call.5
distanceReturns the distance between two points.
dotReturns the dot product of two vectors.1
dstCalculates a distance vector.5
errorfSubmits an error message to the information queue.4
EvaluateAttributeAtCentroidEvaluates at the pixel centroid.5
EvaluateAttributeAtSampleEvaluates at the indexed sample location.5
EvaluateAttributeSnappedEvaluates at the pixel centroid with an offset.5
expReturns the base-e exponent.
exp2Base 2 exponent (per component).
f16tof32Converts the float16 stored in the low-half of the uint to a float.5
f32tof16Converts an input into a float16 type.5
faceforwardReturns -n * sign(dot(i, ng)).
firstbithighGets the location of the first set bit starting from the highest order bit and working downward, per component.5
firstbitlowReturns the location of the first set bit starting from the lowest order bit and working upward, per component.5
floorReturns the greatest integer which is less than or equal to x.
fmaReturns the double-precision fused multiply-addition of a * b + c.5
fmodReturns the floating point remainder of x/y.
fracReturns the fractional part of x.
frexpReturns the mantissa and exponent of x.
fwidthReturns abs(ddx(x)) + abs(ddy(x))
GetRenderTargetSampleCountReturns the number of render-target samples.4
GetRenderTargetSamplePositionReturns a sample position (x,y) for a given sample index.4
GroupMemoryBarrierBlocks execution of all threads in a group until all group shared accesses have been completed.5
GroupMemoryBarrierWithGroupSyncBlocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call.5
InterlockedAddPerforms a guaranteed atomic add of value to the dest resource variable.5
InterlockedAndPerforms a guaranteed atomic and.5
InterlockedCompareExchangeAtomically compares the input to the comparison value and exchanges the result.5
InterlockedCompareStoreAtomically compares the input to the comparison value.5
InterlockedExchangeAssigns value to dest and returns the original value.5
InterlockedMaxPerforms a guaranteed atomic max.5
InterlockedMinPerforms a guaranteed atomic min.5
InterlockedOrPerforms a guaranteed atomic or.5
InterlockedXorPerforms a guaranteed atomic xor.5
isfiniteReturns true if x is finite, false otherwise.
isinfReturns true if x is +INF or -INF, false otherwise.
isnanReturns true if x is NAN or QNAN, false otherwise.
ldexpReturns x * 2exp
lengthReturns the length of the vector v.
lerpReturns x + s(y - x).
litReturns a lighting vector (ambient, diffuse, specular, 1)
logReturns the base-e logarithm of x.
log10Returns the base-10 logarithm of x.
log2Returns the base-2 logarithm of x.
madPerforms an arithmetic multiply/add operation on three values.5
maxSelects the greater of x and y.
minSelects the lesser of x and y.
modfSplits the value x into fractional and integer parts.
msad4Compares a 4-byte reference value and an 8-byte source value and accumulates a vector of 4 sums.5
mulPerforms matrix multiplication using x and y.1
noiseGenerates a random value using the Perlin-noise algorithm.
normalizeReturns a normalized vector.
powReturns xy.
printfSubmits a custom shader message to the information queue.4
Process2DQuadTessFactorsAvgGenerates the corrected tessellation factors for a quad patch.5
Process2DQuadTessFactorsMaxGenerates the corrected tessellation factors for a quad patch.5
Process2DQuadTessFactorsMinGenerates the corrected tessellation factors for a quad patch.5
ProcessIsolineTessFactorsGenerates the rounded tessellation factors for an isoline.5
ProcessQuadTessFactorsAvgGenerates the corrected tessellation factors for a quad patch.5
ProcessQuadTessFactorsMaxGenerates the corrected tessellation factors for a quad patch.5
ProcessQuadTessFactorsMinGenerates the corrected tessellation factors for a quad patch.5
ProcessTriTessFactorsAvgGenerates the corrected tessellation factors for a tri patch.5
ProcessTriTessFactorsMaxGenerates the corrected tessellation factors for a tri patch.5
ProcessTriTessFactorsMinGenerates the corrected tessellation factors for a tri patch.5
radiansConverts x from degrees to radians.1
rcpCalculates a fast, approximate, per-component reciprocal.5
reflectReturns a reflection vector.1
refractReturns the refraction vector.
reversebitsReverses the order of the bits, per component.5
roundRounds x to the nearest integer
rsqrtReturns 1 / sqrt(x)
saturateClamps x to the range [0, 1]1
signComputes the sign of x.
sinReturns the sine of x
sincosReturns the sine and cosine of x.
sinhReturns the hyperbolic sine of x
smoothstepReturns a smooth Hermite interpolation between 0 and 1.
sqrtSquare root (per component)
stepReturns (x >= a) ? 1 : 0
tanReturns the tangent of x
tanhReturns the hyperbolic tangent of x
tex1D(s, t)1D texture lookup.1
tex1D(s, t, ddx, ddy)1D texture lookup.
tex1Dbias1D texture lookup with bias.
tex1Dgrad1D texture lookup with a gradient.
tex1Dlod1D texture lookup with LOD.
tex1Dproj1D texture lookup with projective divide.
tex2D(s, t)2D texture lookup.
tex2D(s, t, ddx, ddy)2D texture lookup.
tex2Dbias2D texture lookup with bias.
tex2Dgrad2D texture lookup with a gradient.
tex2Dlod2D texture lookup with LOD.3
tex2Dproj2D texture lookup with projective divide.
tex3D(s, t)3D texture lookup.
tex3D(s, t, ddx, ddy)3D texture lookup.
tex3Dbias3D texture lookup with bias.
tex3Dgrad3D texture lookup with a gradient.
tex3Dlod3D texture lookup with LOD.
tex3Dproj3D texture lookup with projective divide.
texCUBE(s, t)Cube texture lookup.
texCUBE(s, t, ddx, ddy)Cube texture lookup.
texCUBEbiasCube texture lookup with bias.
texCUBEgradCube texture lookup with a gradient.
texCUBElodCube texture lookup with LOD.
texCUBEprojCube texture lookup with projective divide.
transposeReturns the transpose of the matrix m.1
truncTruncates floating-point value(s) to integer value(s)1

转载于:https://www.cnblogs.com/naturelight/p/5416366.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值