source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/shadow.cg @ 2891

Revision 2891, 1.2 KB checked in by mattausch, 16 years ago (diff)
Line 
1struct appdata {
2        float3 Position : POSITION;
3        float3 Normal : NORMAL;
4};
5
6
7struct vpconn {
8        float4 Hposition : POSITION;
9        float4 TexCoord0 : TEXCOORD0;
10        float4 TexCoord1 : TEXCOORD1;
11        float4 Color0 : COLOR0;
12};
13
14
15vpconn main(appdata IN,
16                        uniform float4x4 WorldViewProj,
17                        uniform float4x4 TexTransform,
18                        uniform float3x3 WorldIT,
19                        uniform float3 LightVec)
20{
21        vpconn OUT;
22       
23        float3 worldNormal = normalize(mul(WorldIT, IN.Normal));
24       
25        float ldotn = max(dot(LightVec, worldNormal), 0.0);
26        OUT.Color0.xyz = ldotn.xxx;
27       
28        float4 tempPos;
29        tempPos.xyz = IN.Position.xyz;
30        tempPos.w = 1.0;
31       
32        OUT.TexCoord0 = mul(TexTransform, tempPos);
33        OUT.TexCoord1 = mul(TexTransform, tempPos);
34       
35        OUT.Hposition = mul(WorldViewProj, tempPos);
36       
37        return OUT;
38}
39
40
41struct v2f_simple {
42        float4 Hposition : POSITION;
43        float4 TexCoord0 : TEXCOORD0;
44        float4 TexCoord1 : TEXCOORD1;
45        float4 Color0 : COLOR0;
46};
47
48
49float4 main(v2f_simple IN,
50                        uniform sampler2D ShadowMap,
51                        uniform sampler2D SpotLight) : COLOR
52{
53        float4 shadow = tex2D(ShadowMap, IN.TexCoord0.xy);
54        float4 spotlight = tex2D(SpotLight, IN.TexCoord1.xy);
55        float4 lighting = IN.Color0;
56        return shadow * spotlight * lighting;
57}
Note: See TracBrowser for help on using the repository browser.