Download Cg Toolkit User`s Manual

Transcript
Basic Profile Sample Shaders
float4 Normal : NORMAL;
float4 TexCoord0 : TEXCOORD0;
float4 Color0 : COLOR0;
};
struct vertout {
float4 Hposition : POSITION;
float4 Color0 : COLOR0;
float4 TexCoord0 : TEXCOORD0;
};
vertout main(app2vert IN,
uniform float4x4 ModelViewProj,
uniform float4x4 ModelView,
uniform float4x4 ModelViewIT,
uniform float4 Constants)
{
vertout OUT;
// we need to figure OUT what the position is
float4 position = IN.Position;
position.z = 0;
position.y = 0;
// add IN the actual base
//
the straw (stored IN
position.x = position.x +
position.z = position.z +
location of
Color0.xz)
IN.Color0.x;
IN.Color0.z;
// figure OUT where the wind is coming from
float4 origin = float4(20,0,20,0);
float4 dir = position - origin;
// find the intensity of the wind
float inten = sin(Constants.x + .2*length(dir)) *
IN.Position.y;
dir = normalize(dir);
// we need to do some Bezier curve stuff here.
float4 ctrl1 = float4(0,0,0,0);
float4 ctrl2 = float4(0,IN.Color0.y/2,0,0);
float4 ctrl3 = float4(dir.x*inten, IN.Color0.y,
dir.z*inten, 0);
// do the Bezier linear interpolation steps
808-00504-0000-004
NVIDIA
147