source: GTP/trunk/App/Demos/Illum/IBRBillboardCloudTrees/OGRE/IBRTreesOGRE/media/general/indirectTexturingLighting_hlsl_VP20.shd @ 1493

Revision 1493, 1.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1struct VS_OUTPUT {
2   float4 Pos:       POSITION;
3   float2 texCoord:  TEXCOORD0;
4   float2 subTexCoord: TEXCOORD1;
5
6   float diffuse: TEXCOORD2;
7};
8
9
10uniform float4x4 worldviewproj;
11uniform float3 lightPosition; // object space
12uniform float3 eyePosition;   // object space
13uniform float4 shininess;
14
15VS_OUTPUT main_vp(
16      float4 position: POSITION,
17      float3 normal: NORMAL,
18      float2 subTexCoord: TEXCOORD0,
19      float4 color: COLOR
20      )
21{
22        VS_OUTPUT Out;
23
24        Out.Pos = mul(worldviewproj, position);
25        Out.subTexCoord = subTexCoord;
26        Out.texCoord = color.xy;
27
28        // Calculate vertex to eye vector
29        float3 vertToEye = position - eyePosition;
30        float aligned = dot(normal, vertToEye);
31
32        // calculate light vector
33        float3 N = normalize(normal);
34        float3 L = normalize(lightPosition - position.xyz);
35
36        // calculate light vector
37        N = normalize(-normal);
38        L = normalize(lightPosition - position.xyz);
39       
40        // Calculate diffuse component
41        Out.diffuse = clamp(dot(N, L) , 0.0, 1.0) + clamp(-dot(N, L) , 0.0, 1.0);
42       
43        return Out;
44}
Note: See TracBrowser for help on using the repository browser.