Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/varianceshadowreceivervp.glsles @ 12091

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

Updated programs and adjusted Material to work with GLSL>150

File size: 3.2 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}
48/////////////////////////////////////////////////////////////////////////////////
49//
50// shadowreceivervp.cg
51//
52// Hamilton Chong
53// (c) 2006
54//
55// This is an example vertex shader for shadow receiver objects. 
56//
57/////////////////////////////////////////////////////////////////////////////////
58
59// Define inputs from application.
60struct VertexIn
61{
62  float4 position       : POSITION;     // vertex position in object space
63  float4 normal         : NORMAL;       // vertex normal in object space
64};
65
66// Define outputs from vertex shader.
67struct Vertex
68{
69  float4 position       : POSITION;     // vertex position in post projective space
70  float4 shadowCoord    : TEXCOORD0;    // vertex position in shadow map coordinates
71  float  diffuse        : TEXCOORD1;    // diffuse shading value
72};
73
74Vertex main(VertexIn         In,
75            uniform float4x4 uModelViewProjection,   // model-view-projection matrix
76            uniform float4   uLightPosition,         // light position in object space
77            uniform float4x4 uModel,                 // model matrix
78            uniform float4x4 uTextureViewProjection  // shadow map's view projection matrix
79            )
80{
81    Vertex Out;
82
83    // compute diffuse shading
84    float3 lightDirection = normalize(uLightPosition.xyz - In.position.xyz);
85    Out.diffuse = dot(In.normal.xyz, lightDirection);
86
87    // compute shadow map lookup coordinates
88    Out.shadowCoord = mul(uTextureViewProjection, mul(uModel, In.position));
89
90    // compute vertex's homogenous screen-space coordinates
91    Out.position = mul(uModelViewProjection, In.position);
92
93    return Out;
94}
Note: See TracBrowser for help on using the repository browser.