Cg Tessellation: 曲面细分

   struct C3E4_Output 
{
  float4 position : POSITION;
  float4 color : COLOR;
};

C3E4_Output C3E4v_twist(float2 position : POSITION,
                        float4 color : COLOR,
                        uniform float twisting)
{
  C3E4_Output OUT;
  float angle = twisting * length(position);
  float cosLength, sinLength;
  sincos(angle, sinLength, cosLength);
  OUT.position[0] = cosLength * position[0] +
                   -sinLength * position[1];
  OUT.position[1] = sinLength * position[0] +
                    cosLength * position[1];
  OUT.position[2] = 0;
  OUT.position[3] = 1;
  OUT.color = color;
  return OUT;
}

 

注意四组图最原始的三个顶点在Twsited后位置没变,所以强化Twisted效果的纯粹是增加了曲面细分。

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

导航