Game Development Reference
In-Depth Information
inout —Shortcut that denotes a parameter as both in and out .
Specify inout if you wish to use a parameter for both input and
output.
void square(inout float x)
{
x=x*x;
}
Here we input the number to be squared through x and also return
the square of x through x .
16.7 Built-in Functions
HLSL has a rich set of built-in functions that are useful for 3D graphics.
The following table is an abridged list of them. In the next two chapters
we will get practice using some of these functions. For now, just get
familiar with them.
Note: For further reference, the complete list of the built-in HLSL
functions can be found in the DirectX documentation, under the Con-
tents tab, then DirectX Graphics\Reference\Shader Reference\High
Level Shader Language\Intrinsic Functions.
Function
Description
abs(x)
Returns | x |.
ceil(x)
Returns the smallest integer
!
x .
clamp(x, a, b)
Clamps x to the range [a, b] and returns the
result.
cos(x)
Returns the cosine of x , where x is in radians.
cross(u, v)
Returns u
v .
degrees(x)
Converts x from radians to degrees.
determinant(M)
Returns the determinant det( M ).
distance(u, v)
Returns the distance vu
between the points u
and v .
dot(u, v)
Returns u
v .
floor(x)
Returns the greatest integer
x .
length(v)
Returns v .
lerp(u, v, t)
Linearly interpolates between u and v based on
the parameter t [0, 1].
log(x)
Returns ln( x ).
log10(x)
Returns log 10 ( x ).
log2(x)
Returns log 2 ( x ).
Search WWH ::




Custom Search