Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Cg/varianceshadowreceivervp.cg

Last change on this file was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.6 KB
Line 
1/////////////////////////////////////////////////////////////////////////////////
2//
3// shadowreceivervp.cg
4//
5// Hamilton Chong
6// (c) 2006
7//
8// This is an example vertex shader for shadow receiver objects. 
9//
10/////////////////////////////////////////////////////////////////////////////////
11
12// Define inputs from application.
13struct VertexIn
14{
15  float4 position       : POSITION;     // vertex position in object space
16  float4 normal         : NORMAL;       // vertex normal in object space
17};
18
19// Define outputs from vertex shader.
20struct Vertex
21{
22  float4 position       : POSITION;     // vertex position in post projective space
23  float4 shadowCoord    : TEXCOORD0;    // vertex position in shadow map coordinates
24  float  diffuse        : TEXCOORD1;    // diffuse shading value
25};
26
27Vertex main(VertexIn         In,
28            uniform float4x4 uModelViewProjection,   // model-view-projection matrix
29            uniform float4   uLightPosition,         // light position in object space
30            uniform float4x4 uModel,                 // model matrix
31            uniform float4x4 uTextureViewProjection  // shadow map's view projection matrix
32            )
33{
34    Vertex Out;
35
36    // compute diffuse shading
37    float3 lightDirection = normalize(uLightPosition.xyz - In.position.xyz);
38    Out.diffuse = dot(In.normal.xyz, lightDirection);
39
40    // compute shadow map lookup coordinates
41    Out.shadowCoord = mul(uTextureViewProjection, mul(uModel, In.position));
42
43    // compute vertex's homogenous screen-space coordinates
44    Out.position = mul(uModelViewProjection, In.position);
45
46    return Out;
47}
Note: See TracBrowser for help on using the repository browser.