Cg MISC

Color interpolation: performed by the rasterization hardware smoothly shades the interior fragments of the triangle. 

=========================================

struct C3E3f_Output 
{
  float4 color : COLOR;
};

C3E3f_Output C3E3f_texture(
float2 texCoord : TEXCOORD0, uniform sampler2D decal)
{
  C3E3f_Output OUT;
  OUT.color = tex2D(decal, texCoord);
  return OUT;
}

=========================================

Function overloading:

You could write two functions and specify that each require a particular profile.

Cg's support for profile-dependent overloading helps you isolate profile-dependent limitations in your Cg programs to helper functions.

=========================================

执行下面的routine: sincos():

void sincos(SCALAR angle, out SCALAR s, out SCALAR c);

Cg会将s和c的值替换成sin(angle)和cos(angle)

 

=========================================

=========================================
Cg的in和inout机制

in参数即call-by-value,如果是同时in-out类似于call-by-reference

posted on 2013-04-06 23:16  0x9801  阅读(153)  评论(0)    收藏  举报

导航