Game Development Reference
In-Depth Information
Date type Descripion
fixed A 12-bit fixed point number (low-precision fixed point. Generally 11 bits, with a
range of -2.0 to +2.0 and 1/256th precision).
bool A Boolean variable (FALSE = 0, TRUE = 1).
sampler* Represents a texture object (sampler1D, sampler2D, sampler3D, samplerCUBE,
samplerRECT).
Cg/HLSL also features vector and matrix data types that are based on the basic data
types, such as float3 and float4x4 . Such data types are quite common when dealing with
3D graphics programming. Cg/HLSL also has struct and array data types, which work in a
similar way to their C equivalents.
Common methods to create shaders
Method Descripion
dot( a, b ) Dot product of two vectors.
cross( A , B ) Cross product of vectors A and B; A and B must be three-
component vectors.
max( a, b ) Maximum of a and b.
min( a , b ) Minimum of a and b.
floor( x ) Get largest integer not greater than x.
round( x ) Get closest integer to x.
ceil( x ) Get smallest integer not less than x.
pow( x , y ) Computes x raised to the power y.
normalize( v ) Returns a vector of length 1 that points in the same direcion as
vector v.
saturate( x ) Clamps x to the [0, 1] range.
tex2D(sampler, x ) 2D texture lookup (sampled data at the locaion indicated by the
texture coordinate set in the sampler object).
The preceding methods are the common methods that you can use to create your shader
with Cg/HLSL. There are a lot of methods that you can also use in Cg/HLSL.
For more details, you can refer to the following site:
http://http.developer.nvidia.com/CgTutorial/cg_tutorial_appendix_e.
html .
Search WWH ::




Custom Search