https://sjbaker.org/wiki/index.php?title=Concise_Cg_built-in_function_table&feed=atom&action=historyConcise Cg built-in function table - Revision history2024-03-29T08:31:41ZRevision history for this page on the wikiMediaWiki 1.24.4https://sjbaker.org/wiki/index.php?title=Concise_Cg_built-in_function_table&diff=713&oldid=prevSteveBaker: New page: The Cg function table: == Functions == {| border="1" cellspacing="0" cellpadding="5" align="center" ! Function !! Description |- | abs( x ) || Absolute value of x . |- | acos( x ) || ...2009-12-24T12:44:20Z<p>New page: The <a href="/wiki/index.php?title=Cg&action=edit&redlink=1" class="new" title="Cg (page does not exist)">Cg</a> function table: == Functions == {| border="1" cellspacing="0" cellpadding="5" align="center" ! Function !! Description |- | abs( x ) || Absolute value of x . |- | acos( x ) || ...</p>
<p><b>New page</b></p><div>The [[Cg]] function table:<br />
<br />
== Functions ==<br />
{| border="1" cellspacing="0" cellpadding="5" align="center"<br />
! Function !! Description<br />
|-<br />
| abs( x ) || Absolute value of x .<br />
|-<br />
| acos( x ) || Arccos of x in range [0, pi], x in [-1, 1].<br />
|-<br />
| all( x ) || true if '''all''' components of x != 0 - false otherwise.<br />
|-<br />
| any( x ) || true if '''any''' component of x != 0 - false otherwise.<br />
|-<br />
| asin( x ) || Arcsin of x in range [-pi/2,pi/2]; x in [-1, 1].<br />
|-<br />
| atan( x ) ||| Arctan of x in range [-pi/2, pi/2].<br />
|-<br />
| atan2( y , x ) || Arctan y/x in range [-pi,pi].<br />
|-<br />
| ceil( x ) || Smallest integer not less than x .<br />
|-<br />
| clamp( x , a , b ) || x clamped to the range [a,b]: a if x<a, b if x>b else returns x.<br />
|-<br />
| cos( x ) || Cos of x.<br />
|-<br />
| cosh( x ) || Hyperbolic cos of x .<br />
|-<br />
| cross( A , B ) || Cross product of vectors A and B (A and B must be three-component).<br />
|-<br />
| ddx( a ) || Partial derivative of a with respect to screen-space x coordinate<br />
|-<br />
| ddy( a ) || Partial derivative of a with respect to screen-space y coordinate<br />
|-<br />
| debug(float4 x) || If compiler DEBUG option is enabled, causes shader to halt with x copied to the COLOR output - otherwise it does nothing.<br />
|-<br />
| degrees( x ) || convert radians to degrees.<br />
|-<br />
| determinant( x ) || Determinant of matrix x.<br />
|-<br />
| distance( p1 , p2 ) || Pythagorean distance between p1 and p2.<br />
|-<br />
| dot( A, B ) || Dot product of A and B.<br />
|-<br />
| exp( x ) || Exponential func: e<sup>x</sup>.<br />
|-<br />
| exp2( x ) || Exponential function 2<sup>x</sup>.<br />
|-<br />
| faceforward( N, I, Ng ) || N if dot( Ng , I ) < 0 otherwise (-N).<br />
|-<br />
| floor( x ) || Largest integer not greater than x.<br />
|-<br />
| fmod( x , y ) || Remainder of x/y (with the same sign as x). If y==0, result is undefined.<br />
|-<br />
| frac( x ) || Fractional part of x.<br />
|-<br />
| frexp( x , out exp ) || Splits x into normalized fraction in the interval [, 1), which is returned, and a power of 2, which is stored in exp . If x==0, both parts of the result are 0.<br />
|-<br />
| isfinite( x ) || Returns true if x is finite.<br />
|-<br />
| isinf( x ) || Returns true if x is infinite.<br />
|-<br />
| isnan( x ) || Returns true if x is NaN.<br />
|-<br />
| ldexp( x , n ) || x * 2<sup>n</sup>.<br />
|-<br />
| length( v ) || Pythagorean length of vector.<br />
|-<br />
| lerp( a , b , f ) || Linear interpolation: (1 - f)* a + b * f. f can be a vector of same length as a & b.<br />
|-<br />
| lit( NdotL , NdotH , m ) || Computes lighting coefficients (m is the shininess). Returns: float4: .x=ambient (always 1), .y=diffuse (0 if N.L < 0), .z=specular (0 if N.L<0 or N.H<0); .w==1.0.<br />
|-<br />
| log( x ) || Natural logarithm (x>0).<br />
|-<br />
| log2( x ) || Log Base 2 (x>0).<br />
|-<br />
| log10( x ) || Log Base 10 (x>0).<br />
|-<br />
| max( a , b ) || Maximum of a and b .<br />
|-<br />
| min( a , b ) || Minimum of a and b .<br />
|-<br />
| modf( x , out ip ) || Splits x into int and frac parts (each with the same sign as x). Stores the int part in ip and returns the fractional part.<br />
|-<br />
| mul( M , N ) || Matrix product of matrix M and matrix N: If M has size AxB, and N has size BxC, returns an AxC.<br />
|-<br />
| mul( M , v ) || Product of matrix M and column vector v: If M has size AxB, and v is Bx1, returns an Ax1.<br />
|-<br />
| mul( v , M ) || Product of row vector v and matrix M: If v is a 1xA and M is AxB, returns a 1xB.<br />
|-<br />
| noise( x ) || Noise function. The returned value is between 0 and 1, and is always the same for a given input value.<br />
|-<br />
| normalize( v ) || Normalize v.<br />
|-<br />
| pow( x , y ) || x<sup>y</sup><br />
|-<br />
| radians( x ) || Converts degrees to radians.<br />
|-<br />
| reflect( I , N ) || Computes reflection of I in a plane with surface normal N. (three-component vectors only).<br />
|-<br />
| refract( I , N , eta ) || Computes refraction of I in a plane with surface normal N and refractive index eta. Returns (0,0,0) for total internal reflection. (three-component vectors only).<br />
|-<br />
| round( x ) || Closest integer to x.<br />
|-<br />
| rsqrt( x ) || Reciprocal square root of x (x>0).<br />
|-<br />
| saturate( x ) || Clamps x to [0, 1].<br />
|-<br />
| sign( x ) || Sign of x (returns -1, 0 or +1)<br />
|-<br />
| sin( x ) || Sin of x.<br />
|-<br />
| sincos(float x , out s , out c ) || s is set to sin(x), and c to cos(x).<br />
|-<br />
| sinh( x ) || Hyperbolic sine of x.<br />
|-<br />
| smoothstep( min , max , x ) || For values of x between min and max , returns a smoothly varying value that ranges from 0 at x==min to 1 at x==max. x is clamped to the range [min,max] and then returns 2*((x-min)/(max-min))<sup>3</sup>+3*((x-min)/(max-min))<sup>2</sup><br />
|-<br />
| step( a , x ) || 0 if x<a, 1 if x>=a<br />
|-<br />
| sqrt( x ) || Square root of x (x>0)<br />
|-<br />
| tan( x ) || Tan of x.<br />
|-<br />
| tanh( x ) || Hyperbolic tan of x.<br />
|-<br />
| tex1D(sampler1D tex , float s ) || 1D nonprojective texture lookup<br />
|-<br />
| tex1D(sampler1D tex , float s , float dsdx , float dsdy ) || 1D nonprojective texture lookup with derivatives<br />
|-<br />
| tex1D(sampler1D tex , float2 sz ) || 1D nonprojective depth compare texture lookup<br />
|-<br />
| tex1D(sampler1D tex , float2 sz , float dsdx , float dsdy ) || 1D nonprojective depth compare texture lookup with derivatives<br />
|-<br />
| tex1Dproj(sampler1D tex , float2 sq ) || 1D projective texture lookup<br />
|-<br />
| tex1Dproj(sampler1D tex , float3 szq ) || 1D projective depth compare texture lookup<br />
|-<br />
| tex2D(sampler2D tex , float2 s ) || 2D nonprojective texture lookup<br />
|-<br />
| tex2D(sampler2D tex , float2 s , float2 dsdx , float2 dsdy ) || 2D nonprojective texture lookup with derivatives<br />
|-<br />
| tex2D(sampler2D tex , float3 sz ) || 2D nonprojective depth compare texture lookup<br />
|-<br />
| tex2D(sampler2D tex , float3 sz , float2 dsdx , float2 dsdy ) || 2D nonprojective depth compare texture lookup with derivatives<br />
|-<br />
| tex2Dproj(sampler2D tex , float3 sq ) || 2D projective texture lookup<br />
|-<br />
| tex2Dproj(sampler2D tex , float4 szq ) || 2D projective depth compare texture lookup<br />
|-<br />
| texRECT(samplerRECT tex , float2 s ) || 2D nonprojective texture rectangle texture lookup (OpenGL)<br />
|-<br />
| texRECT(samplerRECT tex , float2 s , float2 dsdx , float2 dsdy ) || 2D nonprojective texture rectangle texture lookup with derivatives (OpenGL)<br />
|-<br />
| texRECT(samplerRECT tex , float3 sz ) || 2D nonprojective texture rectangle depth compare texture lookup (OpenGL)<br />
|-<br />
| texRECT(samplerRECT tex , float3 sz , float2 dsdx , float2 dsdy ) || 2D nonprojective depth compare texture lookup with derivatives (OpenGL)<br />
|-<br />
| texRECTproj(samplerRECT tex , float3 sq ) || 2D texture rectangle projective texture lookup (OpenGL)<br />
|-<br />
| texRECTproj(samplerRECT tex , float3 szq ) || 2D texture rectangle projective depth compare texture lookup (OpenGL)<br />
|-<br />
| tex3D(sampler3D tex , float3 s ) || 3D nonprojective texture lookup<br />
|-<br />
| tex3D(sampler3D tex , float3 s , float3 dsdx , float3 dsdy ) || 3D nonprojective texture lookup with derivatives<br />
|-<br />
| tex3Dproj(sampler3D tex , float4 sq ) || 3D projective texture lookup<br />
|-<br />
| texCUBE(samplerCUBE tex , float3 s ) || Cubemap nonprojective texture lookup<br />
|-<br />
| texCUBE(samplerCUBE tex , float3 s , float3 dsdx , float3 dsdy ) || Cubemap nonprojective texture lookup with derivatives<br />
|-<br />
| texCUBEproj(samplerCUBE tex , float4 sq ) || Cube map projective texture lookup (ignores q)<br />
|-<br />
| transpose( M ) || transpose of matrix M<br />
|}<br />
<br />
NOTES:<br />
* s indicates a one-, two-, or three-component texture coordinate.<br />
* z indicates a depth comparison value for shadow map lookups.<br />
* q indicates a perspective value, and is used to divide the texture coordinate ( s ) before the texture lookup is performed.<br />
When you use the texture functions that allow specifying a depth comparison value, the associated texture unit must be configured for depth-compare texturing. Otherwise, no depth comparison will actually be performed.</div>SteveBaker