Rev | Line | |
---|
[390] | 1 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // |
---|
| 3 | // shadowcastervp.cg |
---|
| 4 | // |
---|
| 5 | // Hamilton Chong |
---|
| 6 | // (c) 2006 |
---|
| 7 | // |
---|
| 8 | // This is an example vertex shader for shadow caster objects. |
---|
| 9 | // |
---|
| 10 | ///////////////////////////////////////////////////////////////////////////////// |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | // Define inputs from application. |
---|
| 14 | struct VertexIn |
---|
| 15 | { |
---|
| 16 | float4 position : POSITION; // vertex position in object space |
---|
| 17 | float4 normal : NORMAL; // vertex normal in object space |
---|
| 18 | }; |
---|
| 19 | |
---|
| 20 | // Define outputs from vertex shader. |
---|
| 21 | struct VertexOut |
---|
| 22 | { |
---|
| 23 | float4 position : POSITION; // post projection position coordinates |
---|
| 24 | float4 pos : TEXCOORD0; // ditto. Not all hardware allows access values bound to POSITION in fp. |
---|
| 25 | float4 normal : TEXCOORD1; // normal in object space (to be interpolated) |
---|
| 26 | float4 modelPos : TEXCOORD2; // position in object space (to be interpolated) |
---|
| 27 | }; |
---|
| 28 | |
---|
| 29 | VertexOut main( VertexIn In, // vertex to process |
---|
| 30 | uniform float4x4 uModelViewProjection // model-view-projection matrix |
---|
| 31 | ) |
---|
| 32 | { |
---|
| 33 | VertexOut Out; // output data |
---|
| 34 | |
---|
| 35 | // Transform vertex position into post projective (homogenous screen) space. |
---|
| 36 | Out.position = mul(uModelViewProjection, In.position); |
---|
| 37 | Out.pos = mul(uModelViewProjection, In.position); |
---|
| 38 | |
---|
| 39 | // copy over data to interpolate using perspective correct interpolation |
---|
| 40 | Out.normal = float4(In.normal.x, In.normal.y, In.normal.z, 0.0); |
---|
| 41 | Out.modelPos = In.position; |
---|
| 42 | |
---|
| 43 | return Out; |
---|
| 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.