1 | #include "res/shaders/lights.cg"
|
---|
2 | float4x4 mvp : ModelViewProjection;
|
---|
3 | float4x4 mv : ModelView;
|
---|
4 | float4x4 mvit : ModelViewIT;
|
---|
5 |
|
---|
6 |
|
---|
7 | sampler2D stoneTex <string fileName = "stone.jpg";> = sampler_state {
|
---|
8 | minFilter = Linear;
|
---|
9 | magFilter = Linear;
|
---|
10 | wrapS = Repeat;
|
---|
11 | wrapT = Repeat;
|
---|
12 | };
|
---|
13 | sampler2D stone2Tex<string fileName = "stone2.jpg";> = sampler_state {
|
---|
14 | generateMipMap = true;
|
---|
15 | minFilter = Linear;
|
---|
16 | magFilter = Linear;
|
---|
17 | wrapS = Repeat;
|
---|
18 | wrapT = Repeat;
|
---|
19 | };
|
---|
20 |
|
---|
21 | float4 vertex(uniform float4x4 modelViewProj,
|
---|
22 | uniform float4x4 modelView,
|
---|
23 | uniform float4x4 modelViewIT,
|
---|
24 | float4 P : POSITION,
|
---|
25 | float4 N : NORMAL,
|
---|
26 | float2 uvIn : TEXCOORD0,
|
---|
27 | in float4 Cin : COLOR0,
|
---|
28 | out float4 CC : COLOR0,
|
---|
29 | out float3 Pcam : TEXCOORD1,
|
---|
30 | out float3 Ncam : TEXCOORD2,
|
---|
31 | out float2 uv : TEXCOORD0) : POSITION
|
---|
32 | {
|
---|
33 | CC.xyz = normalize(N.xyz);
|
---|
34 | Pcam = mul(modelView, P).xyz;
|
---|
35 | //Ncam = mul(modelViewIT, N).xyz;
|
---|
36 | float3x3 rotation = (float3x3)modelView;
|
---|
37 | Ncam.xyz = mul(rotation,N.xyz);
|
---|
38 |
|
---|
39 | uv = uvIn;
|
---|
40 | return mul(modelViewProj, P);
|
---|
41 | }
|
---|
42 |
|
---|
43 | float3 expand(float3 v) { return (v-0.5)*2; }
|
---|
44 |
|
---|
45 | float4 light( float4 col: COLOR0,
|
---|
46 | in float3 texcoord,
|
---|
47 | float3 Pcam : TEXCOORD1,
|
---|
48 | float3 Ncam : TEXCOORD2) : COLOR
|
---|
49 | {
|
---|
50 | float3 tan = normalize(col.xyz);
|
---|
51 | float3 wo = normalize(-Pcam);
|
---|
52 | float3 result;// = ambient;
|
---|
53 | float3 Nn = normalize(Ncam);
|
---|
54 |
|
---|
55 | float3 scolor = float3(1.0,1.0,1.0);
|
---|
56 | float3 Ln = normalize(float3(0,0,-1)-Pcam);
|
---|
57 | float3 lcolor = float3(1,1,1);
|
---|
58 | float3 Hn = normalize(wo + Ln);
|
---|
59 | float ldn = dot(Ln,Nn);
|
---|
60 | float hdn = dot(Hn,Nn);
|
---|
61 | float4 litV = lit(ldn, hdn, 32);
|
---|
62 |
|
---|
63 | result = tex2D(stone2Tex ,texcoord)*litV.y;
|
---|
64 | return float4(result, 1.);
|
---|
65 | }
|
---|
66 |
|
---|
67 | technique stone <string target = "both";>
|
---|
68 | {
|
---|
69 | pass p0
|
---|
70 | {
|
---|
71 | VertexProgram = compile arbvp1 vertex(mvp, mv, mvit);
|
---|
72 | FragmentProgram = compile arbfp1 light();
|
---|
73 |
|
---|
74 | }
|
---|
75 | } |
---|