1 | sampler2D diffuse <string fileName = "fur_diffuse_256.jpg";> = sampler_state {
|
---|
2 | minFilter = Linear;
|
---|
3 | magFilter = Linear;
|
---|
4 | wrapS = Repeat;
|
---|
5 | wrapT = Repeat;
|
---|
6 | };
|
---|
7 | sampler2D bump<string fileName = "fur_bump.tga";> = sampler_state {
|
---|
8 | generateMipMap = true;
|
---|
9 | minFilter = Linear;
|
---|
10 | magFilter = Linear;
|
---|
11 | wrapS = Repeat;
|
---|
12 | wrapT = Repeat;
|
---|
13 | };
|
---|
14 |
|
---|
15 |
|
---|
16 | float4x4 mvp : ModelViewProjection;
|
---|
17 | float4x4 mv : ModelView;
|
---|
18 | float4x4 mvit : ModelViewIT;
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 | float4 vertexDiff(float4 P : POSITION,
|
---|
23 | float4 N : NORMAL,
|
---|
24 | float2 uvIn : TEXCOORD0,
|
---|
25 | in float4 Cin : COLOR0,
|
---|
26 | out float4 CC : COLOR0,
|
---|
27 | out float3 Pcam : TEXCOORD1,
|
---|
28 | out float3 Ncam : TEXCOORD2,
|
---|
29 | out float2 uv : TEXCOORD0) : POSITION
|
---|
30 | {
|
---|
31 | CC.xyz = normalize(N.xyz);
|
---|
32 | Pcam = mul(mv, P).xyz;
|
---|
33 | Ncam = mul(mvit, N).xyz;
|
---|
34 | return mul(mvp, P);
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | float4 light( float4 col: COLOR0,
|
---|
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 |
|
---|
48 | float3 scolor = float3(1.0,1.0,1.0);
|
---|
49 | float3 Ln = normalize(float3(0,0,-1)-Pcam);
|
---|
50 | float3 lcolor = float3(1,1,1);
|
---|
51 | float3 Hn = normalize(wo + Ln);
|
---|
52 | float ldn = dot(Ln,Nn);
|
---|
53 | float hdn = dot(Hn,Nn);
|
---|
54 | float4 litV = lit(ldn, hdn, 32);
|
---|
55 |
|
---|
56 | result = tex2D(diffuse ,texcoord)*litV.y;
|
---|
57 | return float4(result, 1.);
|
---|
58 | }
|
---|
59 |
|
---|
60 | float4 vertex(uniform float scale,
|
---|
61 | float4 P : POSITION,
|
---|
62 | float4 N : NORMAL,
|
---|
63 | float2 uvIn : TEXCOORD0,
|
---|
64 | in float4 Cin : COLOR0,
|
---|
65 | out float4 CC : COLOR0,
|
---|
66 | out float3 Pcam : TEXCOORD1,
|
---|
67 | out float3 Ncam : TEXCOORD2,
|
---|
68 | out float2 uv : TEXCOORD0) : POSITION
|
---|
69 | {
|
---|
70 | float4 vert = P + float4(N.xyz*scale, 0);
|
---|
71 | uv = uvIn;
|
---|
72 | uv *= 0.25;
|
---|
73 | Ncam = mul(mvit, N).xyz;
|
---|
74 | Pcam = mul(mv, vert);
|
---|
75 | return mul(mvp, vert);
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | float4 fragment( in float3 uv,
|
---|
80 | float3 Pcam : TEXCOORD1,
|
---|
81 | float3 Ncam : TEXCOORD2) : COLOR
|
---|
82 | {
|
---|
83 | float3 wo = normalize(-Pcam);
|
---|
84 | float3 result;// = ambient;
|
---|
85 | float3 alpha = tex2D(bump, uv*2).xyz;
|
---|
86 | if (alpha.r + alpha.g + alpha.b < 1.5) discard;
|
---|
87 | return tex2D(diffuse,uv);
|
---|
88 | }
|
---|
89 |
|
---|
90 | technique red <string target = "both";>
|
---|
91 | {
|
---|
92 | pass p110
|
---|
93 | {
|
---|
94 | VertexProgram = compile arbvp1 vertexDiff();
|
---|
95 | FragmentProgram = compile arbfp1 light();
|
---|
96 | }
|
---|
97 |
|
---|
98 | pass p0
|
---|
99 | {
|
---|
100 | VertexProgram = compile arbvp1 vertex(0.012);
|
---|
101 | FragmentProgram = compile arbfp1 fragment();
|
---|
102 | }
|
---|
103 | pass p1
|
---|
104 | {
|
---|
105 | VertexProgram = compile arbvp1 vertex(0.024);
|
---|
106 | FragmentProgram = compile arbfp1 fragment();
|
---|
107 | }
|
---|
108 | pass p2
|
---|
109 | {
|
---|
110 | VertexProgram = compile arbvp1 vertex(0.036);
|
---|
111 | FragmentProgram = compile arbfp1 fragment();
|
---|
112 | }
|
---|
113 | pass p3
|
---|
114 | {
|
---|
115 | VertexProgram = compile arbvp1 vertex(0.048);
|
---|
116 | FragmentProgram = compile arbfp1 fragment();
|
---|
117 | }
|
---|
118 | pass p4
|
---|
119 | {
|
---|
120 | VertexProgram = compile arbvp1 vertex(0.06);
|
---|
121 | FragmentProgram = compile arbfp1 fragment();
|
---|
122 | }
|
---|
123 | pass p5
|
---|
124 | {
|
---|
125 | VertexProgram = compile arbvp1 vertex(0.072);
|
---|
126 | FragmentProgram = compile arbfp1 fragment();
|
---|
127 | }
|
---|
128 | pass p6
|
---|
129 | {
|
---|
130 | VertexProgram = compile arbvp1 vertex(0.084);
|
---|
131 | FragmentProgram = compile arbfp1 fragment();
|
---|
132 | }
|
---|
133 | pass p7
|
---|
134 | {
|
---|
135 | VertexProgram = compile arbvp1 vertex(0.096);
|
---|
136 | FragmentProgram = compile arbfp1 fragment();
|
---|
137 | }
|
---|
138 | pass p8
|
---|
139 | {
|
---|
140 | VertexProgram = compile arbvp1 vertex(0.108);
|
---|
141 | FragmentProgram = compile arbfp1 fragment();
|
---|
142 | }
|
---|
143 | pass p9
|
---|
144 | {
|
---|
145 | VertexProgram = compile arbvp1 vertex(0.12);
|
---|
146 | FragmentProgram = compile arbfp1 fragment();
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|