-
Notifications
You must be signed in to change notification settings - Fork 1
/
EffectsArmature.fx
1618 lines (1358 loc) · 59.1 KB
/
EffectsArmature.fx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Modified by Torsten Kammer (Cochrane)
*
* I've added real normal mapping here, but left the interface to the program as
* it was. So there is still no real support for ambient lighting, specular
* highlights are always white unless there's a specular texture, and so on.
*
* In front of every function, there is a comment block explaining what I did.
* It's not hard to find: There are no other comments. Other than the changes
* I've mentioned, this code stays fairly close to the original. I've pointed
* out ways it could be changed there, too.
*
* The original code remains, commented out, for reference.
*/
float4x4 World;
float4x4 View;
float4x4 Projection;
float3 CameraPos;
float3 Light1Dir;
float4 Light1Color;
float Light1Intensity;
float Light1ShadowDepth;
float3 Light2Dir;
float4 Light2Color;
float Light2Intensity;
float Light2ShadowDepth;
float3 Light3Dir;
float4 Light3Color;
float Light3Intensity;
float Light3ShadowDepth;
float BumpShadowAmount; // This is no longer used, but I have no idea what happens if I comment it out and don't tell the rest of the program.
float BumpSpecularAmount;
float BumpSpecularGloss;
float Bump1UVScale;
float Bump2UVScale;
float ReflectionAmount;
Texture DiffuseTexture;
Texture LightmapTexture;
Texture BumpTexture;
Texture MaskTexture;
Texture Bump1Texture;
Texture Bump2Texture;
Texture SpecularTexture;
Texture EnvironmentTexture;
bool DisplayTextures;
bool EnableBumpMaps;
bool UseAlternativeReflection;
float4x4 BoneMatrices[59];
struct VertexShaderInput
{
float4 Position: POSITION0;
float4 Normal: NORMAL0;
float4 Color: COLOR0;
float2 TexCoord: TEXCOORD0;
float4 Tangent: TANGENT0;
float4 BoneIndices: BLENDINDICES0;
float4 BoneWeights: BLENDWEIGHT0;
};
struct BasicVertexShaderOutput
{
float4 Position: POSITION0;
float4 Color: COLOR0;
float2 TexCoord: TEXCOORD0;
float3 NormalWorld: TEXCOORD1;
};
struct BumpVertexShaderOutput
{
float4 Position: POSITION0;
float4 Color: COLOR0;
float2 TexCoord: TEXCOORD0;
float3 PositionWorld: TEXCOORD1;
float3 NormalWorld: TEXCOORD2; // You could remove this; I don't use it in any pixel shader anymore, but I know too little of DirectX to dare take it out myself. Remember to remove it from the vertex shader, too. Do keep NormalWorld in the struct above!
float3x3 TangentToWorld: TEXCOORD3;
};
sampler DiffuseTextureSampler = sampler_state {
texture = <DiffuseTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler LightmapTextureSampler = sampler_state {
texture = <LightmapTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler BumpTextureSampler = sampler_state {
texture = <BumpTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler MaskTextureSampler = sampler_state {
texture = <MaskTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler Bump1TextureSampler = sampler_state {
texture = <Bump1Texture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler Bump2TextureSampler = sampler_state {
texture = <Bump2Texture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler SpecularTextureSampler = sampler_state {
texture = <SpecularTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
sampler EnvironmentTextureSampler = sampler_state {
texture = <EnvironmentTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = wrap;
AddressV = wrap;
};
float4 BlendColorLayers_2(float4 color1, float4 color2)
{
float4 color;
color.rgb = color1.rgb + color2.rgb;
color.a = color1.a;
return color;
}
float4 BlendColorLayers_3(float4 color1, float4 color2, float4 color3)
{
float4 color;
color.rgb = color1.rgb + color2.rgb + color3.rgb;
color.a = color1.a;
return color;
}
float4 GetDiffuseColor(float2 texCoord)
{
float4 color = tex2D(DiffuseTextureSampler, texCoord);
if (!DisplayTextures) {
color.rgb = 0.75;
}
return color;
}
float4 GetDiffuseColorShadeless(float2 texCoord)
{
float4 color = tex2D(DiffuseTextureSampler, texCoord);
if (!DisplayTextures) {
color.rgb = 1.0;
}
return color;
}
float CalcPhongShadingFactors_1(float3 normal)
{
float factor1 = saturate(dot(normal, -Light1Dir));
return factor1;
}
float2 CalcPhongShadingFactors_2(float3 normal)
{
float factor1 = saturate(dot(normal, -Light1Dir));
float factor2 = saturate(dot(normal, -Light2Dir));
return float2(factor1, factor2);
}
float3 CalcPhongShadingFactors_3(float3 normal)
{
float factor1 = saturate(dot(normal, -Light1Dir));
float factor2 = saturate(dot(normal, -Light2Dir));
float factor3 = saturate(dot(normal, -Light3Dir));
return float3(factor1, factor2, factor3);
}
float4 CalcPhongShadingColor1(float3 normal, float shadingFactor1)
{
float shading = shadingFactor1;
shading = lerp(1, shading, Light1ShadowDepth);
return float4(Light1Color.rgb * shading, 1);
}
float4 CalcPhongShadingColor2(float3 normal, float shadingFactor2)
{
float shading = shadingFactor2;
shading = lerp(1, shading, Light2ShadowDepth);
return float4(Light2Color.rgb * shading, 1);
}
float4 CalcPhongShadingColor3(float3 normal, float shadingFactor3)
{
float shading = shadingFactor3;
shading = lerp(1, shading, Light3ShadowDepth);
return float4(Light3Color.rgb * shading, 1);
}
/*******************************************************************************
* Original way bumpmaps were handled in XNALara, together with other functions.
*
* Not really sure what it does. Overlay seems to be in the 0-1 range. Makes
* color darker or brighter. Definitely not needed for real normal mapping.
float4 BumpShadowFunc(float4 base, float overlay)
{
float4 output;
output.rgb = base.rgb * (base.rgb + 2 * overlay * (1 - base.rgb));
output.a = base.a;
return output;
}
*/
/*******************************************************************************
* Combines several bump colors to one.
*
* Nothing to change here, but if you want, you can adjust the weights to have
* the detail bump maps feature more prominently.
*/
float4 CombineBumpColors(float4 color0, float4 color1, float amount1, float4 color2, float amount2)
{
float4 color;
color.rgb = color0.rgb + (color1.rgb - 0.5) * amount1 + (color2.rgb - 0.5) * amount2;
color.a = color0.a;
return color;
}
/*******************************************************************************
* Gets the several bump colors from the samplers for …3 shaders.
*
* Nothing to change here, only the normal for disabled normals was weird.
*/
float4 CombinedBumpColor(BumpVertexShaderOutput input)
{
if (!EnableBumpMaps) {
return float4(0.5, 0.5, 1, 1); // Note: After *2-1, will be 0, 0, 1
}
else {
float4 bump0Color = tex2D(BumpTextureSampler, input.TexCoord);
float4 maskColor = tex2D(MaskTextureSampler, input.TexCoord);
float4 bump1Color = tex2D(Bump1TextureSampler, input.TexCoord * Bump1UVScale);
float4 bump2Color = tex2D(Bump2TextureSampler, input.TexCoord * Bump2UVScale);
return CombineBumpColors(bump0Color, bump1Color, maskColor.r, bump2Color, maskColor.g);
}
}
/*******************************************************************************
* Normal from just one bumpmap.
*
* The special treatment for b is odd; it makes all normals point z+, which is
* admittedly likely, but not consistent with CombineBumpColors or the way it's
* normally done.
*
* Changed to uniform scaling. You can try changing back and see what you like
* more.
*/
float3 CalcBumpNormal(float4 bumpColor, BumpVertexShaderOutput input)
{
//float3 bumpNormalT = float3(bumpColor.rg * 2 - 1, bumpColor.b);
float3 bumpNormalT = bumpColor.rgb * 2 - 1;
return normalize(mul(bumpNormalT, input.TangentToWorld));
}
/*******************************************************************************
* Get specular factors for one, two or three lights.
*
* The phongShadingFactor in there is odd, but allowable. If you want, take that
* factor out in the return line and see whether you like the result more;
* highlights in darker areas should become more noticeable.
*
* Now uses reflect() to get the reflection direction. The original code was
* correct, but almost impossible to understand if you don't know Householder
* transformations. There's also a slight chance that HLSL may have a special
* case for this very common mathematical operation.
*
* Since reflect returns a vector with the opposite direction as the old code,
* I've changed cameraDir to match, so the rest of the code won't notice.
*/
float CalcBumpSpecularFactors_1(float3 bumpNormal, BumpVertexShaderOutput input, float phongShadingFactor)
{
//float3 bumpNormal2 = bumpNormal * 2;
//float3 reflLight1Dir = dot(bumpNormal, Light1Dir) * bumpNormal2 - Light1Dir;
float3 reflLight1Dir = reflect(Light1Dir, bumpNormal);
//float3 cameraDir = normalize(input.PositionWorld - CameraPos);
float3 cameraDir = normalize(CameraPos - input.PositionWorld);
float specularFactor1 = saturate(dot(cameraDir, reflLight1Dir));
return phongShadingFactor * pow(specularFactor1, BumpSpecularGloss) * BumpSpecularAmount;
}
/*******************************************************************************
* See above
*/
float2 CalcBumpSpecularFactors_2(float3 bumpNormal, BumpVertexShaderOutput input, float2 phongShadingFactors)
{
//float3 bumpNormal2 = bumpNormal * 2;
//float3 reflLight1Dir = dot(bumpNormal, Light1Dir) * bumpNormal2 - Light1Dir;
//float3 reflLight2Dir = dot(bumpNormal, Light2Dir) * bumpNormal2 - Light2Dir;
float3 reflLight1Dir = reflect(Light1Dir, bumpNormal);
float3 reflLight2Dir = reflect(Light2Dir, bumpNormal);
//float3 cameraDir = normalize(input.PositionWorld - CameraPos);
float3 cameraDir = normalize(CameraPos - input.PositionWorld);
float specularFactor1 = saturate(dot(cameraDir, reflLight1Dir));
float specularFactor2 = saturate(dot(cameraDir, reflLight2Dir));
return phongShadingFactors * pow(float2(specularFactor1, specularFactor2), BumpSpecularGloss) * BumpSpecularAmount;
}
/*******************************************************************************
* See above
*/
float3 CalcBumpSpecularFactors_3(float3 bumpNormal, BumpVertexShaderOutput input, float3 phongShadingFactors)
{
//float3 bumpNormal2 = bumpNormal * 2;
//float3 reflLight1Dir = dot(bumpNormal, Light1Dir) * bumpNormal2 - Light1Dir;
//float3 reflLight2Dir = dot(bumpNormal, Light2Dir) * bumpNormal2 - Light2Dir;
//float3 reflLight3Dir = dot(bumpNormal, Light3Dir) * bumpNormal2 - Light3Dir;
float3 reflLight1Dir = reflect(Light1Dir, bumpNormal);
float3 reflLight2Dir = reflect(Light2Dir, bumpNormal);
float3 reflLight3Dir = reflect(Light3Dir, bumpNormal);
//float3 cameraDir = normalize(input.PositionWorld - CameraPos);
float3 cameraDir = normalize(CameraPos - input.PositionWorld);
float specularFactor1 = saturate(dot(cameraDir, reflLight1Dir));
float specularFactor2 = saturate(dot(cameraDir, reflLight2Dir));
float specularFactor3 = saturate(dot(cameraDir, reflLight3Dir));
return phongShadingFactors * pow(float3(specularFactor1, specularFactor2, specularFactor3), BumpSpecularGloss) * BumpSpecularAmount;
}
/*******************************************************************************
* Calculates color after specular highlights (and originally, bumpmap darkening
* is applied.
*
* This function originally did too many things, and it did them oddly. It was
* here that bump maps were applied, by lightening or darkening the diffuse
* color based on the color values of the bump map (without ever looking at the
* light sources, of course). That's just wrong.
*
* It's other job was to apply the specular color. That is okay and can stay.
*
* Not its job was applying the light color attenuated by the diffuse factor
* ("phong color"). That was done by the shaders instead, directly afterwards.
* I've added it, to be consisted with ApplyBumpBlendSpecular, which does that.
* right away. Note that there, the specular factor is not multiplied by the
* light color, while here it is. That's how it used to be.
*
* By the way, note that this applies the diffuse factor twice: Once here, once
* when calculating the bumpSpecularFactor. Again, that's how XNALara used to do
* it, so I've kept it.
*
* This uses a seperate specular color, which gives very bright highlights. You
* could also try returning saturate(diffuseColor*(1+specular)), which subdues
* and colors them, perhaps too much.
*
* If you want to add a separate specular light color, it would have to be
* applied in this function.
*/
//float4 ApplyBumpBlend(float4 diffuseColor, float4 bumpColor, float bumpSpecularFactor)
float4 ApplyBumpBlend(float4 diffuseColor, float bumpSpecularFactor, float4 phongColor)
{
float4 specular = float4(bumpSpecularFactor, bumpSpecularFactor, bumpSpecularFactor, 0);
//float4 shadowed = BumpShadowFunc(BumpShadowFunc(diffuseColor, 1 - bumpColor.r), 1 - bumpColor.g);
//return saturate(lerp(diffuseColor, shadowed, BumpShadowAmount) + specular);
return saturate(diffuseColor + specular) * phongColor;
}
/*
float4 ApplyBumpBlend(float4 diffuseColor, float4 bumpColor, float bumpSpecularFactor)
{
float4 specular = float4(bumpSpecularFactor, bumpSpecularFactor, bumpSpecularFactor, 0);
float4 shadowed = BumpShadowFunc(BumpShadowFunc(diffuseColor, 1 - bumpColor.r), 1 - bumpColor.g);
return saturate(lerp(diffuseColor, shadowed, BumpShadowAmount) + specular);
}*/
/*******************************************************************************
* This function shouldn't be used, only by shaders that I forgot to adapt.
*/
float4 BumpShadowFunc(float4 base, float overlay)
{
float4 output;
output.rgb = base.rgb * (base.rgb + 2 * overlay * (1 - base.rgb));
output.a = base.a;
return output;
}
/*******************************************************************************
* This version shouldn't be used, only by shaders that I forgot to adapt.
*/
float4 ApplyBumpBlend(float4 diffuseColor, float4 bumpColor, float bumpSpecularFactor)
{
float4 specular = float4(bumpSpecularFactor, bumpSpecularFactor, bumpSpecularFactor, 0);
float4 shadowed = BumpShadowFunc(BumpShadowFunc(diffuseColor, 1 - bumpColor.r), 1 - bumpColor.g);
return saturate(diffuseColor * (1 - BumpShadowAmount) + shadowed * BumpShadowAmount + specular);
}
/*******************************************************************************
* Same as above, but with an additional specular color, and taking into
* account the light color.
*
* In the original version, this also applied the "phong color", i.e. the light
* color applied by the diffuse function.
*/
/*
float4 ApplyBumpBlendSpecular(float4 diffuseColor, float4 bumpColor, float3 bumpSpecularColor, float4 phongColor)
{
//float4 shadowed = BumpShadowFunc(BumpShadowFunc(diffuseColor, 1 - bumpColor.r), 1 - bumpColor.g);
//return saturate(lerp(diffuseColor, shadowed, BumpShadowAmount)) * phongColor + float4(bumpSpecularColor, 0);
return diffuseColor * phongColor + float4(bumpSpecularColor, 0);
}
*/
float4 ApplyBumpBlendSpecular(float4 diffuseColor, float3 bumpSpecularColor, float4 phongColor)
{
//float4 shadowed = BumpShadowFunc(BumpShadowFunc(diffuseColor, 1 - bumpColor.r), 1 - bumpColor.g);
//return saturate(lerp(diffuseColor, shadowed, BumpShadowAmount)) * phongColor + float4(bumpSpecularColor, 0);
return diffuseColor * phongColor + float4(bumpSpecularColor, 0);
}
float4x4 CalcBoneTransform(VertexShaderInput input)
{
float4x4 boneTransform = 0;
boneTransform += BoneMatrices[input.BoneIndices[0]] * input.BoneWeights[0];
boneTransform += BoneMatrices[input.BoneIndices[1]] * input.BoneWeights[1];
boneTransform += BoneMatrices[input.BoneIndices[2]] * input.BoneWeights[2];
boneTransform += BoneMatrices[input.BoneIndices[3]] * input.BoneWeights[3];
return boneTransform;
}
float2 CalculateEnvironmentTexCoord(float3 reflectionDir)
{
float u;
if (UseAlternativeReflection) {
u = (normalize(reflectionDir.xz).x + 1) * 0.5;
}
else {
u = (normalize(reflectionDir.xz).x + 1) * 0.25;
if (reflectionDir.z < 0) {
u = 1 - u;
}
}
float v = (reflectionDir.y + 1) * 0.5;
return float2(u, v);
}
BasicVertexShaderOutput BasicVS(VertexShaderInput input)
{
BasicVertexShaderOutput output;
float4x4 WorldViewProjection = mul(mul(World, View), Projection);
float3x3 World3x3 = (float3x3)World;
float4x4 boneTransform = CalcBoneTransform(input);
output.Position = mul(mul(input.Position, boneTransform), WorldViewProjection);
output.Color = input.Color;
output.TexCoord = input.TexCoord;
float3 normal3 = (float3)input.Normal;
normal3 = mul(normal3, (float3x3)boneTransform);
output.NormalWorld = normalize(mul(normal3, World3x3));
return output;
}
/*******************************************************************************
* Vertex shader for bump mapping.
*
* Not much to say here, because I didn't change it, but if you want different
* orientations for the normals, here is the place. Swap tangentU, tangentV and
* normal in the float3x3 expression below until you're happy.
*/
BumpVertexShaderOutput BumpVS(VertexShaderInput input)
{
float4x4 ViewProjection = mul(View, Projection);
BumpVertexShaderOutput output;
float4x4 boneTransform = CalcBoneTransform(input);
float4x4 fullTransform = mul(boneTransform, World);
float4 positionWorld = mul(input.Position, fullTransform);
output.Position = mul(positionWorld, ViewProjection);
output.Color = input.Color;
output.TexCoord = input.TexCoord;
output.PositionWorld = positionWorld;
output.NormalWorld = normalize(mul(input.Normal, (float3x3) fullTransform));
float3 tangentU = normalize(input.Tangent);
float3 tangentV = normalize(cross(input.Normal, tangentU) * input.Tangent.w);
float3 normal = normalize(input.Normal);
output.TangentToWorld = mul(float3x3(tangentU, tangentV, normal), fullTransform);
return output;
}
/*******************************************************************************
* Pixel shaders that don't bumpmap.
*
* I did not touch them, but I don't particularly like them, either.
*/
float4 DiffusePS_1(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float phongShadingFactor1 = CalcPhongShadingFactors_1(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactor1);
float4 color1 = diffuseColor * phongShadingColor1;
return color1;
}
float4 DiffusePS_2(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float2 phongShadingFactors = CalcPhongShadingFactors_2(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
float4 color1 = diffuseColor * phongShadingColor1;
float4 color2 = diffuseColor * phongShadingColor2;
return BlendColorLayers_2(color1, color2);
}
float4 DiffusePS_3(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float3 phongShadingFactors = CalcPhongShadingFactors_3(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(input.NormalWorld, phongShadingFactors[2]);
float4 color1 = diffuseColor * phongShadingColor1;
float4 color2 = diffuseColor * phongShadingColor2;
float4 color3 = diffuseColor * phongShadingColor3;
return BlendColorLayers_3(color1, color2, color3);
}
float4 DiffuseLightmapPS_1(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float phongShadingFactor = CalcPhongShadingFactors_1(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactor);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = diffuseColor * phongShadingColor1 * lightmapColor;
return color1;
}
float4 DiffuseLightmapPS_2(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float2 phongShadingFactors = CalcPhongShadingFactors_2(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = diffuseColor * phongShadingColor1 * lightmapColor;
float4 color2 = diffuseColor * phongShadingColor2 * lightmapColor;
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseLightmapPS_3(BasicVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float3 phongShadingFactors = CalcPhongShadingFactors_3(input.NormalWorld);
float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(input.NormalWorld, phongShadingFactors[2]);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = diffuseColor * phongShadingColor1 * lightmapColor;
float4 color2 = diffuseColor * phongShadingColor2 * lightmapColor;
float4 color3 = diffuseColor * phongShadingColor3 * lightmapColor;
return BlendColorLayers_3(color1, color2, color3);
}
/*******************************************************************************
* Shaders that do bumpmap.
*
* The general approach for all of them is the same:
* - Calculate the normals at the start, and use them instead of NormalWorld for
* CalcPhongShading… and so on.
* - ApplyBumpBlend takes the phong shading color as a parameter.
* - Both ApplyBumpBlend and ApplyBumpBlendSpecular no longer take the bump
* color as a parameter.
*
* I did not keep the original code for all of them.
*/
float4 DiffuseBumpPS_1(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
// float phongShadingFactor = CalcPhongShadingFactors_1(input.NormalWorld);
// float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactor);
// float4 bumpColor;
// if (EnableBumpMaps) {
// bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
// }
// else {
// bumpColor = float4(0.5, 0.5, 1, 1);
// }
// float3 bumpNormal = CalcBumpNormal(bumpColor, input);
// float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
// float4 color1 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactor) * phongShadingColor1;
// return color1;
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float phongShadingFactor = CalcPhongShadingFactors_1(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactor);
float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactor, phongShadingColor1);
return color1;
}
float4 DiffuseBumpPS_2(BumpVertexShaderOutput input) : COLOR0
{
// float4 diffuseColor = GetDiffuseColor(input.TexCoord);
// diffuseColor *= input.Color;
// float2 phongShadingFactors = CalcPhongShadingFactors_2(input.NormalWorld);
// float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
// float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
// float4 bumpColor;
// if (EnableBumpMaps) {
// bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
// }
// else {
// bumpColor = float4(0.5, 0.5, 1, 1);
// }
// float3 bumpNormal = CalcBumpNormal(bumpColor, input);
// float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
// float4 color1 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactors[0]) * phongShadingColor1;
// float4 color2 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactors[1]) * phongShadingColor2;
// return BlendColorLayers_2(color1, color2);
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float2 phongShadingFactors = CalcPhongShadingFactors_2(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1);
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2);
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseBumpPS_3(BumpVertexShaderOutput input) : COLOR0
{
// float4 diffuseColor = GetDiffuseColor(input.TexCoord);
// diffuseColor *= input.Color;
// float3 phongShadingFactors = CalcPhongShadingFactors_3(input.NormalWorld);
// float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactors[0]);
// float4 phongShadingColor2 = CalcPhongShadingColor2(input.NormalWorld, phongShadingFactors[1]);
// float4 phongShadingColor3 = CalcPhongShadingColor3(input.NormalWorld, phongShadingFactors[2]);
// float4 bumpColor;
// if (EnableBumpMaps) {
// bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
// }
// else {
// bumpColor = float4(0.5, 0.5, 1, 1);
// }
// float3 bumpNormal = CalcBumpNormal(bumpColor, input);
// float3 bumpSpecularFactors = CalcBumpSpecularFactors_3(bumpNormal, input, phongShadingFactors);
// float4 color1 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactors[0]) * phongShadingColor1;
// float4 color2 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactors[1]) * phongShadingColor2;
// float4 color3 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactors[2]) * phongShadingColor3;
// return BlendColorLayers_3(color1, color2, color3);
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float3 phongShadingFactors = CalcPhongShadingFactors_3(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(bumpNormal, phongShadingFactors[2]);
float3 bumpSpecularFactors = CalcBumpSpecularFactors_3(bumpNormal, input, phongShadingFactors);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1);
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2);
float4 color3 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[2], phongShadingColor3);
return BlendColorLayers_3(color1, color2, color3);
}
float4 DiffuseLightmapBumpPS_1(BumpVertexShaderOutput input) : COLOR0
{
// float4 diffuseColor = GetDiffuseColor(input.TexCoord);
// diffuseColor *= input.Color;
// float phongShadingFactor = CalcPhongShadingFactors_1(input.NormalWorld);
// float4 phongShadingColor1 = CalcPhongShadingColor1(input.NormalWorld, phongShadingFactor);
// float4 bumpColor;
// if (EnableBumpMaps) {
// bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
// }
// else {
// bumpColor = float4(0.5, 0.5, 1, 1);
// }
// float3 bumpNormal = CalcBumpNormal(bumpColor, input);
// float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
// float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
// float4 color1 = ApplyBumpBlend(diffuseColor, bumpColor, bumpSpecularFactor) * phongShadingColor1 * lightmapColor;
// return color1;
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float phongShadingFactor = CalcPhongShadingFactors_1(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactor);
float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactor, phongShadingColor1) * lightmapColor;
return color1;
}
float4 DiffuseLightmapBumpPS_2(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float2 phongShadingFactors = CalcPhongShadingFactors_2(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2) * lightmapColor;
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseLightmapBumpPS_3(BumpVertexShaderOutput input) : COLOR0
{
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float3 phongShadingFactors = CalcPhongShadingFactors_3(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(bumpNormal, phongShadingFactors[2]);
float3 bumpSpecularFactors = CalcBumpSpecularFactors_3(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2) * lightmapColor;
float4 color3 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[2], phongShadingColor3) * lightmapColor;
return BlendColorLayers_3(color1, color2, color3);
}
float4 DiffuseLightmapBump3PS_1(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor = CombinedBumpColor(input);
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float phongShadingFactor = CalcPhongShadingFactors_1(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactor);
float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactor, phongShadingColor1) * lightmapColor;
return color1;
}
float4 DiffuseLightmapBump3PS_2_HQ(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor = CombinedBumpColor(input);
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float2 phongShadingFactors = CalcPhongShadingFactors_2(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2) * lightmapColor;
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseLightmapBump3PS_2_LQ(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor = CombinedBumpColor(input);
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float2 phongShadingFactors = CalcPhongShadingFactors_2(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2) * lightmapColor;
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseLightmapBump3PS_3(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
float4 bumpColor = CombinedBumpColor(input);
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float3 phongShadingFactors = CalcPhongShadingFactors_3(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(bumpNormal, phongShadingFactors[2]);
float3 bumpSpecularFactors = CalcBumpSpecularFactors_3(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 color1 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[0], phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[1], phongShadingColor2) * lightmapColor;
float4 color3 = ApplyBumpBlend(diffuseColor, bumpSpecularFactors[2], phongShadingColor3) * lightmapColor;
return BlendColorLayers_3(color1, color2, color3);
}
float4 DiffuseLightmapBumpSpecularPS_1(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
// Fix issue reported by o0Crofty0o - this shader should not use CombinedBumpColor.
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float phongShadingFactor = CalcPhongShadingFactors_1(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactor);
float bumpSpecularFactor = CalcBumpSpecularFactors_1(bumpNormal, input, phongShadingFactor);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 specularColor = tex2D(SpecularTextureSampler, input.TexCoord);
float3 bumpSpecularColor1 = bumpSpecularFactor * specularColor.rgb * Light1Intensity;
float4 color1 = ApplyBumpBlendSpecular(diffuseColor, float4(bumpSpecularColor1,0), phongShadingColor1) * lightmapColor;
return color1;
}
float4 DiffuseLightmapBumpSpecularPS_2(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
// Fix issue reported by o0Crofty0o - this shader should not use CombinedBumpColor.
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float2 phongShadingFactors = CalcPhongShadingFactors_2(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float2 bumpSpecularFactors = CalcBumpSpecularFactors_2(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 specularColor = tex2D(SpecularTextureSampler, input.TexCoord);
float3 bumpSpecularColor1 = bumpSpecularFactors[0] * specularColor.rgb * Light1Intensity;
float3 bumpSpecularColor2 = bumpSpecularFactors[1] * specularColor.rgb * Light2Intensity;
float4 color1 = ApplyBumpBlendSpecular(diffuseColor, bumpSpecularColor1, phongShadingColor1) * lightmapColor;
float4 color2 = ApplyBumpBlendSpecular(diffuseColor, bumpSpecularColor2, phongShadingColor2) * lightmapColor;
return BlendColorLayers_2(color1, color2);
}
float4 DiffuseLightmapBumpSpecularPS_3(BumpVertexShaderOutput input) : COLOR0
{
float4 diffuseColor = GetDiffuseColor(input.TexCoord);
diffuseColor *= input.Color;
// Fix issue reported by o0Crofty0o - this shader should not use CombinedBumpColor.
float4 bumpColor;
if (EnableBumpMaps) {
bumpColor = tex2D(BumpTextureSampler, input.TexCoord);
}
else {
bumpColor = float4(0.5, 0.5, 1, 1);
}
float3 bumpNormal = CalcBumpNormal(bumpColor, input);
float3 phongShadingFactors = CalcPhongShadingFactors_3(bumpNormal);
float4 phongShadingColor1 = CalcPhongShadingColor1(bumpNormal, phongShadingFactors[0]);
float4 phongShadingColor2 = CalcPhongShadingColor2(bumpNormal, phongShadingFactors[1]);
float4 phongShadingColor3 = CalcPhongShadingColor3(bumpNormal, phongShadingFactors[2]);
float3 bumpSpecularFactors = CalcBumpSpecularFactors_3(bumpNormal, input, phongShadingFactors);
float4 lightmapColor = tex2D(LightmapTextureSampler, input.TexCoord);
float4 specularColor = tex2D(SpecularTextureSampler, input.TexCoord);
float3 bumpSpecularColor1 = bumpSpecularFactors[0] * specularColor.rgb * Light1Intensity;
float3 bumpSpecularColor2 = bumpSpecularFactors[1] * specularColor.rgb * Light2Intensity;