Inherent HLSL Functions

Source: Internet
Author: User
View shader every 30 minutes -- (1) Inherent HLSL function [intrinsic functions (DirectX HLSL )]It looks convenient to put it on the blog. This is on msdn, and it is also available in DirectX documentation.
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.

Name Syntax Description
ABS ABS (X) Absolute value (per component ).
ACOs ACOs (X) Returns the arccosine of each component of X.
All All (X) Test if all components of X are nonzero.
Any Any (X) Test if any component of X is nonzero.
Asfloat Asfloat (X) Convert the input type to a float.
Asin Asin (X) Returns the arcsine of each component of X.
Asint Asint (X) Convert the input type to an integer.
Asuint Asuint (X) Convert the input type to an unsigned integer.
Atan Atan (X) Returns the arctangent of X.
Atan2 Atan2 (Y, X) Returns the arctangent of two values (x, y ).
Ceil Ceil (X) Returns the smallest integer which is greater than or equal to X.
Clamp Clamp (x, Min, max) Clamps X to the range [min, Max].
Clip Clip (X) Discards the current pixel, if any component of X is less than zero.
Cos Cos (X) Returns the cosine of X.
Cosh Cosh (X) Returns the hyperbolic cosine of X.
Cross Cross (x, y) Returns the cross product of two 3D vectors.
D3dcolortoubyte4 D3dcolortoubyte4 (X) Swizzles and scales components of the 4D vector X to compensate for the lack of ubyte4 support in some hardware.
DDX DDX (X) Returns the partial derivative of X with respect to the screen-space X-coordinate.
Ddy Ddy (X) Returns the partial derivative of X with respect to the screen-Space Y-coordinate.
Degrees Degrees (X) Converts X from radians to degrees.
Determinant Determinant (m) Returns the determinant of the square matrix m.
Distance Distance (x, y) Returns the distance between two points.
Dot DOT (x, y) Returns the dot product of two vectors.
Exp Exp (X) Returns the base-e exponent.
Exp2 Exp2 (X) Base 2 exponent (per component ).
Faceforward Faceforward (n, I, NG) Returns-N * sign (• (I, NG )).
Floor Floor (X) Returns the greatest integer which is less than or equal to X.
Fmod Fmod (x, y) Returns the floating point remainder of x/y.
Frac Frac (X) Returns the fractional part of X.
Frexp Frexp (x, exp) Returns the mantissa and exponent of X.
Fwidth Fwidth (X) Returns ABS (DDX (x) + ABS (ddy (x ))
Getrendertargetsamplecount Getrendertargetsamplecount () Returns the number of render-target samples.
Getrendertargetsampleposition Getrendertargetsampleposition (X) Returns a sample position (x, y) for a given sample index.
Isfinite Isfinite (X) Returns true if X is finite, false otherwise.
Isinf Isinf (X) Returns true if X is + inf or-INF, false otherwise.
Isnan Isnan (X) Returns true if X is Nan or qnan, false otherwise.
Ldexp Ldexp (x, exp) Returns x * 2exp
Length Length (V) Returns the length of the vector v.
Lerp Lerp (X, Y, S) Returns x + S (Y-x ).
Bytes Round (n • L, n • H, m) Returns a lighting vector (ambient, diffuse, specular, 1)
Log Log (X) Returns the base-e logarithm of X.
Log10 Log10 (X) Returns the base-10 logarithm of X.
Log2 Log2 (X) Returns the base-2 logarithm of X.
Max Max (x, y) Selects the greater of X and Y.
Min Min (x, y) Selects the lesser of X and Y.
MODF MODF (x, out IP) Splits the value x into fractional and integer parts.
Mul Mul (x, y) Performs matrix multiplication using X and Y.
Noise Noise (X) Generates a random value using the Perlin-noise algorithm.
Normalize Normalize (X) Returns a normalized vector.
POW Pow (x, y) Returns XY.
Radians Radians (X) Converts X from degrees to radians.
Reflect Reflect (I, n) Returns a reflection vector.
Refract Refract (I, n, R) Returns the refraction vector.
Round Round (X) Rounds X to the nearest integer
Rsqrt Rsqrt (X) Returns 1/SQRT (X)
Saturate Saturate (X) Clamps X to the range [0, 1]
Sign Sign (X) Computes the sign of X.
Sin Sin (X) Returns the sine of X
Sincos Sincos (x, out S, out C) Returns the sine and cosine of X.
Sinh Sinh (X) Returns the hyperbolic sine of X
Smoothstep Smoothstep (Min, Max, X) Returns a smooth Hermite interpolation between 0 and 1.
SQRT SQRT (X) Square Root (per component)
Step STEP (A, X) Returns (x> = )? 1: 0
Tan Tan (X) Returns the tangent of X
Tanh Tanh (X) Returns the hyperbolic tangent of X
Tex1d Tex1d (S, T) 1D texture lookup.
Tex1dbias Tex1dbias (S, T) 1D texture lookup with bias.
Tex1dgrad Tex1dgrad (S, T, DDX, ddy) 1D texture lookup with a gradient.
Tex1dlevels Tex1dlevels (S, T) 1D texture lookup with OpenGL.
Tex1dproj Tex1dproj (S, T) 1D texture lookup with projective divide.
Tex2d Tex2d (S, T) 2D Texture lookup.
Tex2dbias Tex2dbias (S, T) 2D Texture lookup with bias.
Tex2dgrad Tex2dgrad (S, T, DDX, ddy) 2D Texture lookup with a gradient.
Tex2dlevels Tex2dlevels (S, T) 2D Texture lookup with dashboard.
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.
Tex3dlevels Tex3dlevels (S, T) 3D texture lookup with dashboard.
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 Tex3dlevels (S, T) Cube Texture lookup with OpenGL.
Texcubeproj Texcubeproj (S, T) Cube Texture lookup with projective divide.
Transpose Transpose (m) Returns the transpose of the matrix m.
Trunc Trunc (X) Truncates floating-point value (s) to integer value (s)

Table 3-1 HLSL built-in functions

Function Name usage

ABS calculates the absolute value of the input value.

ACOs returns the inverse cosine of the input value.

The value of all is not 0.

Any tests any non-zero value in the input value.

Asin returns the arc sine of the input value.

Atan returns the arc tangent of the input value.

Atan2 returns the arc tangent value of Y/X.

Ceil returns the smallest integer greater than or equal to the input value.

Clamp limits the input value to the range of [min, Max.

Clip drops the current pixel if any element in the input vector is less than 0.

Cos returns the cosine of the input value.

Cosh returns the hyperbolic cosine of the input value.

Cross returns the cross product of two 3D vectors.

DDX returns the partial derivative of the X axis of the screen coordinate.

Ddy returns the partial derivative of the Y axis of the screen coordinate.

Degrees to degrees

Determinant returns the value of the input matrix.

Distance returns the distance between two input points.

Dot returns the dot product of two vectors.

Exp returns the base number of E, and the input value is the exponential value.

Exp2 returns an exponential function value that uses 2 as the base and the input value as the index.

Faceforward checks whether a polygon is located on the front.

Floor returns the largest integer less than or equal to X.

Fmod returns the floating point remainder of A/B.

Frac returns the fractional part of the input value.

Frexp returns the ending and exponent of the input value

Fwidth returns ABS (DDX (x) + ABS (ddy (x )).

Isfinite returns true if the input value is finite; otherwise, false.

If the input value of isinf is infinite, true is returned.

Isnan returns true if the input value is Nan or qnan.

Returns x * 2 ^ exp for the inverse operation of ldexp frexp.

Len/lenth returns the length of the input vector.

Lerp performs Interpolation on input values.

Returns the illumination vector (Environment light, diffuse reflection light, mirror highlight, 1 ).

Log returns the base-e logarithm.

Log10 returns the base-10 logarithm.

Log2 returns the base 2 logarithm.

Max returns one of the two input values.

Min returns a smaller value of the two input values.

MODF splits the input values into integers and decimals.

Mul returns the product of the input matrix.

Normalize returns the normalized vector, defined as X/length (X ).

Pow returns the specified power of the input value.

The conversion from radians angle to radians.

Reflect returns the reflected light from the incident light I to the surface normal n.

Refract returns the X-ray V of the incident light I, the surface normal N, and the refractive index ETA.

Round returns an integer closest to the input value.

Rsqrt returns the reciprocal of the square root of the input value.

Saturate limits the input value to [0, 1.

Sign calculates the sign of the input value.

Sin calculates the sine of the input value.

Sincos returns the sine and cosine of the input value.

Sinh returns the hyperbolic sine of X.

Smoothstep returns an interpolation that changes smoothly between input values.

SQRT returns the square root of the input value.

Step return (x> = )? 1: 0.

Tan returns the tangent of the input value.

Fanh returns the hyperbolic tangent of the input value.

Transpose returns the transpose of the input matrix.

Tex1d * 1D texture query.

Tex2d * 2D Texture query.

Tex3d * 3D texture query.

Texcube * Cube Texture query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.