Graphics Reference
In-Depth Information
provides HLSL shader programs with full access to the functionality provided by the as-
sembly instruction set. In a few cases, intrinsic functions also provide an optimized set of
common mathematical operations, which spares the programmer from implementing them
manually. The following sections contain tables listing intrinsic functions grouped by cat-
egory, with a brief description for each. For a full description (including return types and
parameters), consult the SDK documentation
6.7.1 Mathematical Functions
Vector/Matrix Operations
Table 6.5 contains a list of all vector and matrix math intrinsics supported by HLSL. These
intrinsics implement mathematical operations that can be performed on vector and matrix
data types.
Intrinsic
Description
mul
Matrix/Matrix, Matrix/Vector, or Vector/Vector multiplication
dot
Vector dot product
cross
Vector cross product
Matrix transpose
transpose
determinant
Matrix determinant
Vector length/magnitude
length
normalize
Geometric vector normalize
distance
Computes the distance between two points
Flips a surface normal direction such that it points in a direction op-
posite to an incident vector
faceforward
reflect
Computes a reflection vector, given normal and incident vectors
Computes a refraction vector, given an entering direction, normal vec-
tor, and refraction index
refract
Table 6.5. Vector/matrix math intrinsics.
General Math Functions
Table 6.6 contains a listing of HLSL's general math intrinsics. These instrinsics are mostly
scalar math operations, similar to those found in the C Standard Library.
Search WWH ::




Custom Search