ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/vsh.cg
Revision: 1.3
Committed: Tue Oct 5 07:35:26 2004 UTC (19 years, 8 months ago) by root
Branch: MAIN
CVS Tags: knowngood
Changes since 1.2: +4 -3 lines
Log Message:
*** empty log message ***

File Contents

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