1 | struct appdata {
|
---|
2 | float3 Position : POSITION;
|
---|
3 | float3 Normal : NORMAL;
|
---|
4 | };
|
---|
5 |
|
---|
6 |
|
---|
7 | struct vpconn {
|
---|
8 | float4 Hposition : POSITION;
|
---|
9 | float4 TexCoord0 : TEXCOORD0;
|
---|
10 | float4 TexCoord1 : TEXCOORD1;
|
---|
11 | float4 Color0 : COLOR0;
|
---|
12 | };
|
---|
13 |
|
---|
14 |
|
---|
15 | vpconn 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 |
|
---|
41 | struct v2f_simple {
|
---|
42 | float4 Hposition : POSITION;
|
---|
43 | float4 TexCoord0 : TEXCOORD0;
|
---|
44 | float4 TexCoord1 : TEXCOORD1;
|
---|
45 | float4 Color0 : COLOR0;
|
---|
46 | };
|
---|
47 |
|
---|
48 |
|
---|
49 | float4 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 | } |
---|