home *** CD-ROM | disk | FTP | other *** search
- //simple per-pixel phong shading
-
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //combined world,view,projection transform
- float4x4 matWorldViewProj;
- //world transform
- float4x4 matWorld;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Normal : NORMAL;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float3 Normal : TEXCOORD2;
- float3 Pos2 : TEXCOORD1;
- float2 Tex0 : TEXCOORD0;
- float4 Clr : COLOR;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //copy normal, and tex coord, set color
- Out.Normal=mul(matWorld,In.Normal.xyz);
- Out.Tex0=In.Tex0;
- Out.Clr=float4(1,1,1,1);
-
- //calc transformed position
- Out.Pos=mul(matWorldViewProj,In.Pos);
- Out.Pos2=mul(matWorld,In.Pos);
-
- //spit out the results
- return Out;
- }
-