… | |
… | |
13 | float3 WorldPos : TEXCOORD3; |
13 | float3 WorldPos : TEXCOORD3; |
14 | float3 WorldView : TEXCOORD4; |
14 | float3 WorldView : TEXCOORD4; |
15 | }; |
15 | }; |
16 | |
16 | |
17 | // vertex shader |
17 | // vertex shader |
18 | vertexOut main(vertexIn IN, // vertex input from app |
18 | vertexOut main(vertexIn IN) |
19 | uniform float4x4 WorldViewProj, |
|
|
20 | uniform float4x4 WorldProj |
|
|
21 | //uniform float3 LightPos |
|
|
22 | ) |
|
|
23 | { |
19 | { |
24 | vertexOut OUT; // output of the vertex shader |
20 | vertexOut OUT; // output of the vertex shader |
25 | OUT.WorldNormal = mul(WorldProj, IN.Normal).xyz; |
21 | |
|
|
22 | OUT.WorldNormal = mul(glstate.matrix.modelview[0], IN.Normal).xyz; |
26 | // position in object coords: |
23 | // position in object coords: |
27 | float4 Po = float4(IN.Position.x,IN.Position.y, IN.Position.z,1.0); |
24 | float4 Po = float4(IN.Position.x,IN.Position.y, IN.Position.z,1.0); |
28 | float3 Pw = mul(WorldViewProj, Po).xyz; // pos in world coord |
25 | float3 Pw = mul(glstate.matrix.mvp, Po).xyz; // pos in world coord |
29 | |
26 | |
30 | float3 LightPos = { 0, 0, 0}; |
27 | float3 LightPos = { 0, 0, 0}; |
31 | OUT.WorldPos = Pw; // pos in world coords |
28 | OUT.WorldPos = Pw; // pos in world coords |
32 | OUT.LightVec = LightPos - Pw; // light vector |
29 | OUT.LightVec = LightPos - Pw; // light vector |
33 | OUT.TexCoord = IN.UV; // original tex coords |
30 | OUT.TexCoord = IN.UV; // original tex coords |
34 | // view vector in world coords: |
31 | // view vector in world coords: |
35 | OUT.WorldView = normalize (WorldViewProj[3].xyz - Pw); |
32 | OUT.WorldView = normalize (glstate.matrix.mvp[3].xyz - Pw); |
36 | // pos in clip coords: |
33 | // pos in clip coords: |
37 | OUT.HPosition = mul(WorldViewProj, Po); |
34 | OUT.HPosition = mul(glstate.matrix.mvp, Po); |
38 | return OUT; // output of vertex shader |
35 | return OUT; // output of vertex shader |
39 | } |
36 | } |
40 | |
37 | |