ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/vsh.cg
(Generate patch)

Comparing libgender/vsh.cg (file contents):
Revision 1.5 by root, Tue Oct 5 08:13:01 2004 UTC vs.
Revision 1.6 by root, Tue Oct 5 10:28:49 2004 UTC

1// data from application to vertex program
2struct vertexIn { 1struct vertexIn {
3 float3 Position : POSITION; // pre-defined registers
4 float4 UV : TEXCOORD0;
5 float4 Normal : NORMAL;
6};
7// vertex shader to pixel shader
8struct vertexOut {
9 float4 HPosition : POSITION; 2 float4 Position : POSITION;
10 float4 TexCoord : TEXCOORD0; 3 float4 Normal : NORMAL;
11 float3 LightVec : TEXCOORD1; 4 float4 UV : TEXCOORD0;
12 float3 WorldNormal : TEXCOORD2;
13 float3 WorldPos : TEXCOORD3;
14 float3 WorldView : TEXCOORD4;
15}; 5};
16 6
17// vertex shader 7struct vertexOut {
8 float4 HPosition : POSITION;
9 float4 TexCoord : TEXCOORD0;
10 float3 LightVec : TEXCOORD1;
11 float3 EyeVec : TEXCOORD2;
12 float3 WorldNormal : TEXCOORD3;
13};
14
18vertexOut main(vertexIn IN) 15vertexOut main(vertexIn IN)
19{ 16{
20 vertexOut OUT; // output of the vertex shader 17 vertexOut OUT;
21 18
22 OUT.WorldNormal = mul(glstate.matrix.modelview[0], IN.Normal).xyz; 19 float3 LightPos = { 0, 0, 0 };
23 // position in object coords:
24 float4 Po = float4(IN.Position.x,IN.Position.y, IN.Position.z,1.0);
25 float3 Pw = mul(glstate.matrix.mvp, Po).xyz; // pos in world coord
26 20
27 float3 LightPos = { 0, 0, 0}; 21 float4 Pw = mul (glstate.matrix.mvp, IN.Position);
28 OUT.WorldPos = Pw; // pos in world coords 22
29 OUT.LightVec = LightPos - Pw; // light vector 23 OUT.WorldNormal = normalize (mul (glstate.matrix.modelview[0], IN.Normal).xyz);
30 OUT.TexCoord = IN.UV; // original tex coords 24 OUT.EyeVec = normalize (mul (glstate.matrix.modelview[0], IN.Position).xyz);
31 // view vector in world coords: 25 OUT.LightVec = normalize (LightPos - IN.Position).xyz;
32 OUT.WorldView = normalize (glstate.matrix.mvp[3].xyz - Pw); 26 OUT.TexCoord = IN.UV;
33 // pos in clip coords: 27 OUT.HPosition = Pw;
34 OUT.HPosition = mul(glstate.matrix.mvp, Po); 28
35 return OUT; // output of vertex shader 29 return OUT;
36} 30}
37 31

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines