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