summaryrefslogtreecommitdiff
path: root/src/mesh/assimp-master/tools/assimp_view/Shaders.cpp
blob: 9fd05ca8d5a316ed9c46834c0b3641cdf3846b0f (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------

Copyright (c) 2006-2022, assimp team

All rights reserved.

Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.

* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.

* Neither the name of the assimp team, nor the names of its
  contributors may be used to endorse or promote products
  derived from this software without specific prior
  written permission of the assimp team.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "assimp_view.h"

namespace AssimpView {

// ------------------------------------------------------------------------------------------------
std::string g_szNormalsShader = std::string(

        // World * View * Projection matrix\n"
        // NOTE: Assume that the material uses a WorldViewProjection matrix\n"
        "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
        "float4 OUTPUT_COLOR;\n"

        // Vertex shader input structure
        "struct VS_INPUT\n"
        "{\n"
        "// Position\n"
        "float3 Position : POSITION;\n"
        "};\n"

        // Vertex shader output structure for pixel shader usage
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "};\n"

        // Vertex shader output structure for FixedFunction usage
        "struct VS_OUTPUT_FF\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float4 Color : COLOR;\n"
        "};\n"

        // Vertex shader for rendering normals using pixel shader
        "VS_OUTPUT RenderNormalsVS(VS_INPUT IN)\n"
        "{\n"
        "// Initialize the output structure with zero\n"
        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"

        "// Multiply with the WorldViewProjection matrix\n"
        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"

        "return Out;\n"
        "}\n"

        // Vertex shader for rendering normals using fixed function pipeline
        "VS_OUTPUT_FF RenderNormalsVS_FF(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT_FF Out;\n"
        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
        "Out.Color = OUTPUT_COLOR;\n"
        "return Out;\n"
        "}\n"

        // Pixel shader
        "float4 RenderNormalsPS() : COLOR\n"
        "{\n"
        "return OUTPUT_COLOR;\n"
        "}\n"

        // Technique for the normal rendering effect (ps_2_0)
        "technique RenderNormals\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "PixelShader = compile ps_2_0 RenderNormalsPS();\n"
        "VertexShader = compile vs_2_0 RenderNormalsVS();\n"
        "}\n"
        "};\n"

        // Technique for the normal rendering effect (fixed function)
        "technique RenderNormals_FF\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "VertexShader = compile vs_2_0 RenderNormalsVS_FF();\n"
        "ColorOp[0] = SelectArg1;\n"
        "ColorArg0[0] = Diffuse;\n"
        "AlphaOp[0] = SelectArg1;\n"
        "AlphaArg0[0] = Diffuse;\n"
        "}\n"
        "};\n");

// ------------------------------------------------------------------------------------------------
std::string g_szSkyboxShader = std::string(

        // Sampler and texture for the skybox
        "textureCUBE lw_tex_envmap;\n"
        "samplerCUBE EnvironmentMapSampler = sampler_state\n"
        "{\n"
        "Texture = (lw_tex_envmap);\n"
        "AddressU = CLAMP;\n"
        "AddressV = CLAMP;\n"
        "AddressW = CLAMP;\n"

        "MAGFILTER = linear;\n"
        "MINFILTER = linear;\n"
        "};\n"

        // World * View * Projection matrix\n"
        // NOTE: Assume that the material uses a WorldViewProjection matrix\n"
        "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"

        // Vertex shader input structure
        "struct VS_INPUT\n"
        "{\n"
        "float3 Position : POSITION;\n"
        "float3 Texture0 : TEXCOORD0;\n"
        "};\n"

        // Vertex shader output structure
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float3 Texture0 : TEXCOORD0;\n"
        "};\n"

        // Vertex shader
        "VS_OUTPUT RenderSkyBoxVS(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT Out;\n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"

        // Set z to w to ensure z becomes 1.0 after the division through w occurs
        "Out.Position.z = Out.Position.w;\n"

        // Simply pass through texture coordinates
        "Out.Texture0 = IN.Texture0;\n"

        "return Out;\n"
        "}\n"

        // Pixel shader
        "float4 RenderSkyBoxPS(float3 Texture0 : TEXCOORD0) : COLOR\n"
        "{\n"
        // Lookup the skybox texture
        "return texCUBE(EnvironmentMapSampler,Texture0) ;\n"
        "}\n"

        // Technique for the skybox shader (ps_2_0)
        "technique RenderSkyBox\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "ZWriteEnable = FALSE;\n"
        "FogEnable = FALSE;\n"
        "CullMode = NONE;\n"

        "PixelShader = compile ps_2_0 RenderSkyBoxPS();\n"
        "VertexShader = compile vs_2_0 RenderSkyBoxVS();\n"
        "}\n"
        "};\n"

        // -------------- same for static background image -----------------
        "texture TEXTURE_2D;\n"
        "sampler TEXTURE_SAMPLER = sampler_state\n"
        "{\n"
        "Texture = (TEXTURE_2D);\n"
        "};\n"

        "struct VS_OUTPUT2\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float2 TexCoord0 : TEXCOORD0;\n"
        "};\n"

        "VS_OUTPUT2 RenderImageVS(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
        "{\n"
        "VS_OUTPUT2 Out;\n"

        "Out.Position.xy = INPosition.xy;\n"
        "Out.Position.z = Out.Position.w = 1.0f;\n"
        "Out.TexCoord0 = INTexCoord0;\n"

        "return Out;\n"
        "}\n"

        "float4 RenderImagePS(float2 IN : TEXCOORD0) : COLOR\n"
        "{\n"
        "return tex2D(TEXTURE_SAMPLER,IN);\n"
        "}\n"

        // Technique for the background image shader (ps_2_0)
        "technique RenderImage2D\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "ZWriteEnable = FALSE;\n"
        "FogEnable = FALSE;\n"
        "CullMode = NONE;\n"

        "PixelShader = compile ps_2_0 RenderImagePS();\n"
        "VertexShader = compile vs_2_0 RenderImageVS();\n"
        "}\n"
        "};\n");

std::string g_szDefaultShader = std::string(

        // World * View * Projection matrix
        // NOTE: Assume that the material uses a WorldViewProjection matrix
        "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
        "float4x4 World					: WORLD;\n"
        "float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"

        // light colors
        "float3 afLightColor[5];\n"
        // light direction
        "float3 afLightDir[5];\n"

        // position of the camera in worldspace\n"
        "float3 vCameraPos : CAMERAPOSITION;\n"

        // Bone matrices
        //	"#ifdef AV_SKINNING \n"
        "float4x3 gBoneMatrix[60]; \n"
        //	"#endif // AV_SKINNING \n"

        // Vertex shader input structure
        "struct VS_INPUT\n"
        "{\n"
        "float3 Position : POSITION;\n"
        "float3 Normal : NORMAL;\n"
        //		"#ifdef AV_SKINNING \n"
        "float4 BlendIndices : BLENDINDICES;\n"
        "float4 BlendWeights : BLENDWEIGHT;\n"
        //		"#endif // AV_SKINNING \n"
        "};\n"

        // Vertex shader output structure for pixel shader usage
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float3 ViewDir : TEXCOORD0;\n"
        "float3 Normal : TEXCOORD1;\n"
        "};\n"

        // Vertex shader output structure for fixed function
        "struct VS_OUTPUT_FF\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float4 Color : COLOR;\n"
        "};\n"

        // Vertex shader for pixel shader usage
        "VS_OUTPUT DefaultVShader(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT Out;\n"

        //		"#ifdef AV_SKINNING \n"
        "float4 weights = IN.BlendWeights; \n"
        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
        "float4 localPos = float4( IN.Position, 1.0f); \n"
        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
        //		"#else \n"
        //		"float3 objPos = IN.Position; \n"
        //		"#endif // AV_SKINNING \n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
        "Out.ViewDir = vCameraPos - WorldPos;\n"
        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"

        "return Out;\n"
        "}\n"

        // Vertex shader for fixed function pipeline
        "VS_OUTPUT_FF DefaultVShader_FF(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT_FF Out;\n"

        //		"#ifdef AV_SKINNING \n"
        "float4 weights = IN.BlendWeights; \n"
        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
        "float4 localPos = float4( IN.Position, 1.0f); \n"
        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
        //		"#else \n"
        //		"float3 objPos = IN.Position; \n"
        //		"#endif // AV_SKINNING \n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"

        "float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"

        // per-vertex lighting. We simply assume light colors of unused lights to be black
        "Out.Color = float4( 0.2f, 0.2f, 0.2f, 1.0f); \n"
        "for( int a = 0; a < 2; a++)\n"
        "  Out.Color.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
        "return Out;\n"
        "}\n"

        // Pixel shader for one light
        "float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "float3 Normal = normalize(IN.Normal);\n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
        "float fHalfLambert = L1*L1;\n"
        "OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
        "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,ViewDir),9));\n"
        "}\n"
        "return OUT;\n"
        "}\n"

        // Pixel shader for two lights
        "float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "float3 Normal = normalize(IN.Normal);\n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (ViewDir,Normal);\n"
        "float fHalfLambert = L1*L1;\n"
        "OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
        "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[0]),9));\n"
        "}\n"
        "{\n"
        "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (ViewDir,Normal);\n"
        "float fHalfLambert = L1*L1;\n"
        "OUT.rgb += afLightColor[1] * (fHalfLambert +\n"
        "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[1]),9));\n"
        "}\n"
        "return OUT;\n"
        "}\n"
        // ----------------------------------------------------------------------------
        "float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "float3 Normal = normalize(IN.Normal);\n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "float L1 = dot(Normal,afLightDir[0]);\n"
        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
        "OUT.rgb += afLightColor[0] * ((L1) +\n"
        "pow(dot(Reflect,ViewDir),9));\n"
        "}\n"

        "return OUT;\n"
        "}\n"
        // ----------------------------------------------------------------------------
        "float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "float3 Normal = normalize(IN.Normal);\n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "float L1 = dot(Normal,afLightDir[0]);\n"
        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
        "OUT.rgb += afLightColor[0] * ((L1) +\n"
        "pow(dot(Reflect,ViewDir),9));\n"
        "}\n"
        "{\n"
        "float L1 = dot(Normal,afLightDir[1]);\n"
        "float3 Reflect = reflect (Normal,afLightDir[1]);\n"
        "OUT.rgb += afLightColor[1] * ((L1) +\n"
        "pow(dot(Reflect,ViewDir),9));\n"
        "}\n"
        "return OUT;\n"
        "}\n"

        // Technique for the default effect
        "technique DefaultFXSpecular_D1\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "PixelShader = compile ps_3_0 DefaultPShaderSpecular_D1();\n"
        "VertexShader = compile vs_3_0 DefaultVShader();\n"
        "}\n"
        "};\n"
        "technique DefaultFXSpecular_D2\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "PixelShader = compile ps_3_0 DefaultPShaderSpecular_D2();\n"
        "VertexShader = compile vs_3_0 DefaultVShader();\n"
        "}\n"
        "};\n"

        // Technique for the default effect (ps_2_0)
        "technique DefaultFXSpecular_PS20_D1\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D1();\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "}\n"
        "};\n"
        "technique DefaultFXSpecular_PS20_D2\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D2();\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "}\n"
        "};\n"

        // Technique for the default effect using the fixed function pixel pipeline
        "technique DefaultFXSpecular_FF\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "CullMode=none;\n"
        "VertexShader = compile vs_2_0 DefaultVShader_FF();\n"
        "ColorOp[0] = SelectArg1;\n"
        "ColorArg0[0] = Diffuse;\n"
        "AlphaOp[0] = SelectArg1;\n"
        "AlphaArg0[0] = Diffuse;\n"
        "}\n"
        "};\n");

std::string g_szMaterialShader = std::string(

        // World * View * Projection matrix
        // NOTE: Assume that the material uses a WorldViewProjection matrix
        "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
        "float4x4 World					: WORLD;\n"
        "float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"

        "#ifndef AV_DISABLESSS\n"
        "float4x3 ViewProj;\n"
        "float4x3 InvViewProj;\n"
        "#endif\n"

        "float4 DIFFUSE_COLOR;\n"
        "float4 SPECULAR_COLOR;\n"
        "float4 AMBIENT_COLOR;\n"
        "float4 EMISSIVE_COLOR;\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "float SPECULARITY;\n"
        "float SPECULAR_STRENGTH;\n"
        "#endif\n"
        "#ifdef AV_OPACITY\n"
        "float TRANSPARENCY;\n"
        "#endif\n"

        // light colors (diffuse and specular)
        "float4 afLightColor[5];\n"
        "float4 afLightColorAmbient[5];\n"

        // light direction
        "float3 afLightDir[5];\n"

        // position of the camera in worldspace
        "float3 vCameraPos : CAMERAPOSITION;\n"

        // Bone matrices
        "#ifdef AV_SKINNING \n"
        "float4x3 gBoneMatrix[60]; \n"
        "#endif // AV_SKINNING \n"

        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "texture DIFFUSE_TEXTURE;\n"
        "sampler DIFFUSE_SAMPLER\n"
        "{\n"
        "Texture = <DIFFUSE_TEXTURE>;\n"
        "#ifdef AV_WRAPU\n"
        "AddressU = WRAP;\n"
        "#endif\n"
        "#ifdef AV_MIRRORU\n"
        "AddressU = MIRROR;\n"
        "#endif\n"
        "#ifdef AV_CLAMPU\n"
        "AddressU = CLAMP;\n"
        "#endif\n"
        "#ifdef AV_WRAPV\n"
        "AddressV = WRAP;\n"
        "#endif\n"
        "#ifdef AV_MIRRORV\n"
        "AddressV = MIRROR;\n"
        "#endif\n"
        "#ifdef AV_CLAMPV\n"
        "AddressV = CLAMP;\n"
        "#endif\n"
        "};\n"
        "#endif // AV_DIFFUSE_TEXTUR\n"

        "#ifdef AV_DIFFUSE_TEXTURE2\n"
        "texture DIFFUSE_TEXTURE2;\n"
        "sampler DIFFUSE_SAMPLER2\n"
        "{\n"
        "Texture = <DIFFUSE_TEXTURE2>;\n"
        "};\n"
        "#endif // AV_DIFFUSE_TEXTUR2\n"

        "#ifdef AV_SPECULAR_TEXTURE\n"
        "texture SPECULAR_TEXTURE;\n"
        "sampler SPECULAR_SAMPLER\n"
        "{\n"
        "Texture = <SPECULAR_TEXTURE>;\n"
        "};\n"
        "#endif // AV_SPECULAR_TEXTUR\n"

        "#ifdef AV_AMBIENT_TEXTURE\n"
        "texture AMBIENT_TEXTURE;\n"
        "sampler AMBIENT_SAMPLER\n"
        "{\n"
        "Texture = <AMBIENT_TEXTURE>;\n"
        "};\n"
        "#endif // AV_AMBIENT_TEXTUR\n"

        "#ifdef AV_LIGHTMAP_TEXTURE\n"
        "texture LIGHTMAP_TEXTURE;\n"
        "sampler LIGHTMAP_SAMPLER\n"
        "{\n"
        "Texture = <LIGHTMAP_TEXTURE>;\n"
        "};\n"
        "#endif // AV_LIGHTMAP_TEXTURE\n"

        "#ifdef AV_OPACITY_TEXTURE\n"
        "texture OPACITY_TEXTURE;\n"
        "sampler OPACITY_SAMPLER\n"
        "{\n"
        "Texture = <OPACITY_TEXTURE>;\n"
        "};\n"
        "#endif // AV_OPACITY_TEXTURE\n"

        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "texture EMISSIVE_TEXTURE;\n"
        "sampler EMISSIVE_SAMPLER\n"
        "{\n"
        "Texture = <EMISSIVE_TEXTURE>;\n"
        "};\n"
        "#endif // AV_EMISSIVE_TEXTUR\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "texture NORMAL_TEXTURE;\n"
        "sampler NORMAL_SAMPLER\n"
        "{\n"
        "Texture = <NORMAL_TEXTURE>;\n"
        "};\n"
        "#endif // AV_NORMAL_TEXTURE\n"

        "#ifdef AV_SKYBOX_LOOKUP\n"
        "textureCUBE lw_tex_envmap;\n"
        "samplerCUBE EnvironmentMapSampler = sampler_state\n"
        "{\n"
        "Texture = (lw_tex_envmap);\n"
        "AddressU = CLAMP;\n"
        "AddressV = CLAMP;\n"
        "AddressW = CLAMP;\n"

        "MAGFILTER = linear;\n"
        "MINFILTER = linear;\n"
        "};\n"
        "#endif // AV_SKYBOX_LOOKUP\n"

        // Vertex shader input structure
        "struct VS_INPUT\n"
        "{\n"
        "float3 Position : POSITION;\n"
        "float3 Normal : NORMAL;\n"
        "float4 Color : COLOR0;\n"
        "float3 Tangent   : TANGENT;\n"
        "float3 Bitangent : BINORMAL;\n"
        "float2 TexCoord0 : TEXCOORD0;\n"
        "#ifdef AV_TWO_UV \n"
        "float2 TexCoord1 : TEXCOORD1;\n"
        "#endif \n"
        "#ifdef AV_SKINNING \n"
        "float4 BlendIndices : BLENDINDICES;\n"
        "float4 BlendWeights : BLENDWEIGHT;\n"
        "#endif // AV_SKINNING \n"
        "};\n"

        // Vertex shader output structure for pixel shader usage
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float3 ViewDir : TEXCOORD0;\n"

        "float4 Color : COLOR0;\n"

        "#ifndef AV_NORMAL_TEXTURE\n"
        "float3 Normal  : TEXCOORD1;\n"
        "#endif\n"

        "float2 TexCoord0 : TEXCOORD2;\n"
        "#ifdef AV_TWO_UV \n"
        "float2 TexCoord1 : TEXCOORD3;\n"
        "#endif \n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3 Light0 : TEXCOORD3;\n"
        "float3 Light1 : TEXCOORD4;\n"
        "#endif\n"
        "};\n"

        // Vertex shader output structure for fixed function pixel pipeline
        "struct VS_OUTPUT_FF\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float4 DiffuseColor : COLOR0;\n"
        "float4 SpecularColor : COLOR1;\n"
        "float2 TexCoord0 : TEXCOORD0;\n"
        "};\n"

        // Selective SuperSampling in screenspace for reflection lookups
        "#define GetSSSCubeMap(_refl) (texCUBElod(EnvironmentMapSampler,float4(_refl,0.0f)).rgb) \n"

        // Vertex shader for pixel shader usage and one light
        "VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"

        "#ifdef AV_SKINNING \n"
        "float4 weights = IN.BlendWeights; \n"
        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
        "float4 localPos = float4( IN.Position, 1.0f); \n"
        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
        "#else \n"
        "float3 objPos = IN.Position; \n"
        "#endif // AV_SKINNING \n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
        "Out.TexCoord0 = IN.TexCoord0;\n"
        "#ifdef AV_TWO_UV \n"
        "Out.TexCoord1 = IN.TexCoord1;\n"
        "#endif\n"
        "Out.Color = IN.Color;\n"

        "#ifndef AV_NORMAL_TEXTURE\n"
        "Out.ViewDir = vCameraPos - WorldPos;\n"
        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
        "#endif\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
        "float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
        "Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
        "Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
        "#endif\n"
        "return Out;\n"
        "}\n"

        // Vertex shader for pixel shader usage and two lights
        "VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"

        "#ifdef AV_SKINNING \n"
        "float4 weights = IN.BlendWeights; \n"
        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
        "float4 localPos = float4( IN.Position, 1.0f); \n"
        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
        "#else \n"
        "float3 objPos = IN.Position; \n"
        "#endif // AV_SKINNING \n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
        "Out.TexCoord0 = IN.TexCoord0;\n"
        "#ifdef AV_TWO_UV \n"
        "Out.TexCoord1 = IN.TexCoord1;\n"
        "#endif\n"
        "Out.Color = IN.Color;\n"

        "#ifndef AV_NORMAL_TEXTURE\n"
        "Out.ViewDir = vCameraPos - WorldPos;\n"
        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
        "#endif\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
        "float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
        "Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
        "Out.Light1         = normalize(mul(WTTS, afLightDir[1] ));\n"
        "Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
        "#endif\n"
        "return Out;\n"
        "}\n"

        // Vertex shader for zero to five lights using the fixed function pixel pipeline
        "VS_OUTPUT_FF MaterialVShader_FF(VS_INPUT IN)\n"
        "{\n"
        "VS_OUTPUT_FF Out = (VS_OUTPUT_FF)0;\n"

        "#ifdef AV_SKINNING \n"
        "float4 weights = IN.BlendWeights; \n"
        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
        "float4 localPos = float4( IN.Position, 1.0f); \n"
        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
        "#else \n"
        "float3 objPos = IN.Position; \n"
        "#endif // AV_SKINNING \n"

        // Multiply with the WorldViewProjection matrix
        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
        "float3 worldPos = mul( float4( objPos, 1.0f), World);\n"
        "float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"
        "Out.TexCoord0 = IN.TexCoord0;\n"

        // calculate per-vertex diffuse lighting including ambient part
        "float4 diffuseColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
        "for( int a = 0; a < 2; a++) \n"
        "  diffuseColor.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
        // factor in material properties and a bit of ambient lighting
        "Out.DiffuseColor = diffuseColor * DIFFUSE_COLOR + float4( 0.2f, 0.2f, 0.2f, 1.0f) * AMBIENT_COLOR; ; \n"

        // and specular including emissive part
        "float4 specularColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
        "#ifdef AV_SPECULAR_COMPONENT\n"
        "float3 viewDir = normalize( worldPos - vCameraPos); \n"
        "for( int a = 0; a < 2; a++) \n"
        "{ \n"
        "  float3 reflDir = reflect( afLightDir[a], worldNormal); \n"
        "  float specIntensity = pow( saturate( dot( reflDir, viewDir)), SPECULARITY) * SPECULAR_STRENGTH; \n"
        "  specularColor.rgb += afLightColor[a] * specIntensity; \n"
        "} \n"
        "#endif // AV_SPECULAR_COMPONENT\n"
        // factor in material properties and the emissive part
        "Out.SpecularColor = specularColor * SPECULAR_COLOR + EMISSIVE_COLOR; \n"

        "return Out;\n"
        "}\n"

        // Pixel shader - one light
        "float4 MaterialPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3 IN_Light0 = normalize(IN.Light0);\n"
        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
        "#else\n"
        "float3 Normal = normalize(IN.Normal);\n"
        "#endif \n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"
        "#ifdef AV_SPECULAR_COMPONENT\n"
        "float3 Reflect = normalize(reflect (-ViewDir,Normal));\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"

        "{\n"
        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 =  dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_0 IN_Light0\n"
        // would need to convert the reflection vector into world space ....
        // simply let it ...
        "#else\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_0 afLightDir[0]\n"
        "#endif\n"
        "#ifdef AV_DIFFUSE_TEXTURE2\n"
        "float fHalfLambert = 1.f;\n"
        "#else\n"
        "float fHalfLambert = L1*L1;\n"
        "#endif \n"
        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert * IN.Color.rgb +\n"
        "#else\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert * IN.Color.rgb +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifndef AV_SKYBOX_LOOKUP\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#else\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SKYBOX_LOOKUP\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"

        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"
        "#ifdef AV_OPACITY\n"
        "OUT.a = TRANSPARENCY;\n"
        "#endif\n"
        "#ifdef AV_LIGHTMAP_TEXTURE\n"
        "OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
        "#endif\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
        "#endif\n"
        "return OUT;\n"

        "#undef AV_LIGHT_0\n"
        "}\n"

        // Pixel shader - two lights
        "float4 MaterialPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3 IN_Light0 = normalize(IN.Light0);\n"
        "float3 IN_Light1 = normalize(IN.Light1);\n"
        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
        "#else\n"
        "float3 Normal = normalize(IN.Normal);\n"
        "#endif \n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"
        "#ifdef AV_SPECULAR_COMPONENT\n"
        "float3 Reflect = -normalize(reflect (ViewDir,Normal));\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"

        "{\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_0 IN_Light0\n"
        "#else\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_0 afLightDir[0]\n"
        "#endif\n"
        "float fHalfLambert = L1*L1;\n"

        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
        "#else\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert  * IN.Color.rgb +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifndef AV_SKYBOX_LOOKUP\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#else\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SKYBOX_LOOKUP\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"
        "{\n"
        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_1 IN_Light1\n"
        "#else\n"
        "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
        "#define AV_LIGHT_1 afLightDir[1]\n"
        "#endif\n"
        "float fHalfLambert = L1*L1;\n"
        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
        "#else\n"
        "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * fHalfLambert   * IN.Color.rgb +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifndef AV_SKYBOX_LOOKUP\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#else\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SKYBOX_LOOKUP\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"
        "#ifdef AV_OPACITY\n"
        "OUT.a = TRANSPARENCY;\n"
        "#endif\n"
        "#ifdef AV_LIGHTMAP_TEXTURE\n"
        "OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
        "#endif\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
        "#endif\n"
        "return OUT;\n"

        "#undef AV_LIGHT_0\n"
        "#undef AV_LIGHT_1\n"
        "}\n"

        // Same pixel shader again, one light
        "float4 MaterialPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3 IN_Light0 = normalize(IN.Light0);\n"
        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
        "#else\n"
        "float3 Normal = normalize(IN.Normal);\n"
        "#endif \n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,IN_Light0);\n"
        "#else\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
        "#endif\n"
        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
        "#else\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"

        "#ifdef AV_OPACITY\n"
        "OUT.a = TRANSPARENCY;\n"
        "#endif\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
        "#endif\n"
        "return OUT;\n"
        "}\n"

        // Same pixel shader again, two lights
        "float4 MaterialPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
        "{\n"
        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"

        "#ifdef AV_NORMAL_TEXTURE\n"
        "float3 IN_Light0 = normalize(IN.Light0);\n"
        "float3 IN_Light1 = normalize(IN.Light1);\n"
        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0) - 1.0f);\n"
        "#else\n"
        "float3 Normal = normalize(IN.Normal);\n"
        "#endif \n"
        "float3 ViewDir = normalize(IN.ViewDir);\n"

        "{\n"
        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,IN_Light0);\n"
        "#else\n"
        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
        "#endif\n"
        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
        "#else\n"
        "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"
        "{\n"
        "#ifdef AV_NORMAL_TEXTURE\n"
        "float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,IN_Light1);\n"
        "#else\n"
        "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
        "float3 Reflect = reflect (Normal,afLightDir[1]);\n"
        "#endif\n"
        "#ifdef AV_DIFFUSE_TEXTURE\n"
        "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
        "#else\n"
        "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
        "#endif // !AV_DIFFUSE_TEXTURE\n"

        "#ifdef AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_SPECULAR_TEXTURE\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#else\n"
        "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
        "#endif // !AV_SPECULAR_TEXTURE\n"
        "#endif // !AV_SPECULAR_COMPONENT\n"
        "#ifdef AV_AMBIENT_TEXTURE\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
        "#else\n"
        "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
        "#endif // !AV_AMBIENT_TEXTURE\n"
        "#ifdef AV_EMISSIVE_TEXTURE\n"
        "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
        "#else \n"
        "EMISSIVE_COLOR.rgb;\n"
        "#endif // !AV_EMISSIVE_TEXTURE\n"
        "}\n"

        "#ifdef AV_OPACITY\n"
        "OUT.a = TRANSPARENCY;\n"
        "#endif\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
        "#endif\n"
        "return OUT;\n"
        "}\n"

        // Technique for the material effect
        "technique MaterialFXSpecular_D1\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#else\n"
        "#ifdef AV_OPACITY\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#endif \n"
        "#endif\n"

        "PixelShader = compile ps_3_0 MaterialPShaderSpecular_D1();\n"
        "VertexShader = compile vs_3_0 MaterialVShader_D1();\n"
        "}\n"
        "};\n"
        "technique MaterialFXSpecular_D2\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#else\n"
        "#ifdef AV_OPACITY\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#endif \n"
        "#endif\n"

        "PixelShader = compile ps_3_0 MaterialPShaderSpecular_D2();\n"
        "VertexShader = compile vs_3_0 MaterialVShader_D2();\n"
        "}\n"
        "};\n"

        // Technique for the material effect (ps_2_0)
        "technique MaterialFXSpecular_PS20_D1\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "#ifdef AV_OPACITY_TEXTURE\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#else\n"
        "#ifdef AV_OPACITY\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#endif \n"
        "#endif\n"

        "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D1();\n"
        "VertexShader = compile vs_2_0 MaterialVShader_D1();\n"
        "}\n"
        "};\n"

        "technique MaterialFXSpecular_PS20_D2\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "//CullMode=none;\n"

        "#ifdef AV_OPACITY_TEXTURE\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#else\n"
        "#ifdef AV_OPACITY\n"
        "AlphaBlendEnable=TRUE;"
        "SrcBlend = srcalpha;\n"
        "DestBlend = invsrcalpha;\n"
        "#endif \n"
        "#endif\n"

        "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D2();\n"
        "VertexShader = compile vs_2_0 MaterialVShader_D2();\n"
        "}\n"
        "};\n"

        // Technique for the material effect using fixed function pixel pipeline
        "technique MaterialFX_FF\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "//CullMode=none;\n"
        "SpecularEnable = true; \n"
        "VertexShader = compile vs_2_0 MaterialVShader_FF();\n"
        "ColorOp[0] = Modulate;\n"
        "ColorArg0[0] = Texture;\n"
        "ColorArg1[0] = Diffuse;\n"
        "AlphaOp[0] = Modulate;\n"
        "AlphaArg0[0] = Texture;\n"
        "AlphaArg1[0] = Diffuse;\n"
        "}\n"
        "};\n");

std::string g_szPassThroughShader = std::string(
        "texture TEXTURE_2D;\n"
        "sampler TEXTURE_SAMPLER = sampler_state\n"
        "{\n"
        "Texture = (TEXTURE_2D);\n"
        "MinFilter = POINT;\n"
        "MagFilter = POINT;\n"
        "};\n"

        // Vertex Shader output for pixel shader usage
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "float2 TexCoord0 : TEXCOORD0;\n"
        "};\n"

        // vertex shader for pixel shader usage
        "VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
        "{\n"
        "VS_OUTPUT Out;\n"

        "Out.Position = INPosition;\n"
        "Out.TexCoord0 = INTexCoord0;\n"

        "return Out;\n"
        "}\n"

        // simply lookup a texture
        "float4 PassThrough_PS(float2 IN : TEXCOORD0) : COLOR\n"
        "{\n"
        "  return tex2D(TEXTURE_SAMPLER,IN);\n"
        "}\n"

        // visualize the alpha channel (in black) -> use a
        "float4 PassThroughAlphaA_PS(float2 IN : TEXCOORD0) : COLOR\n"
        "{\n"
        "  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).a);\n"
        "}\n"

        // visualize the alpha channel (in black) -> use r
        "float4 PassThroughAlphaR_PS(float2 IN : TEXCOORD0) : COLOR\n"
        "{\n"
        "  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).r);\n"
        "}\n"

        // Simple pass-through technique
        "technique PassThrough\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "FillMode=Solid;\n"
        "ZEnable = FALSE;\n"
        "CullMode = none;\n"
        "AlphaBlendEnable = TRUE;\n"
        "SrcBlend =srcalpha;\n"
        "DestBlend =invsrcalpha;\n"
        "PixelShader = compile ps_2_0 PassThrough_PS();\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "}\n"
        "};\n"

        // Pass-through technique which visualizes the texture's alpha channel
        "technique PassThroughAlphaFromA\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "FillMode=Solid;\n"
        "ZEnable = FALSE;\n"
        "CullMode = none;\n"
        "AlphaBlendEnable = TRUE;\n"
        "SrcBlend =srcalpha;\n"
        "DestBlend =invsrcalpha;\n"
        "PixelShader = compile ps_2_0 PassThroughAlphaA_PS();\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "}\n"
        "};\n"

        // Pass-through technique which visualizes the texture's red channel
        "technique PassThroughAlphaFromR\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "FillMode=Solid;\n"
        "ZEnable = FALSE;\n"
        "CullMode = none;\n"
        "AlphaBlendEnable = TRUE;\n"
        "SrcBlend =srcalpha;\n"
        "DestBlend =invsrcalpha;\n"
        "PixelShader = compile ps_2_0 PassThroughAlphaR_PS();\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "}\n"
        "};\n"

        // technique for fixed function pixel pipeline
        "technique PassThrough_FF\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "ZEnable = FALSE;\n"
        "CullMode = none;\n"
        "AlphaBlendEnable = TRUE;\n"
        "SrcBlend =srcalpha;\n"
        "DestBlend =invsrcalpha;\n"
        "VertexShader = compile vs_2_0 DefaultVShader();\n"
        "ColorOp[0] = SelectArg1;\n"
        "ColorArg0[0] = Texture;\n"
        "AlphaOp[0] = SelectArg1;\n"
        "AlphaArg0[0] = Texture;\n"
        "}\n"
        "};\n");

std::string g_szCheckerBackgroundShader = std::string(

        // the two colors used to draw the checker pattern
        "float3 COLOR_ONE = float3(0.4f,0.4f,0.4f);\n"
        "float3 COLOR_TWO = float3(0.6f,0.6f,0.6f);\n"

        // size of a square in both x and y direction
        "float SQUARE_SIZE = 10.0f;\n"

        // vertex shader output structure
        "struct VS_OUTPUT\n"
        "{\n"
        "float4 Position : POSITION;\n"
        "};\n"

        // vertex shader
        "VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
        "{\n"
        "VS_OUTPUT Out;\n"

        "Out.Position = INPosition;\n"
        "return Out;\n"
        "}\n"

        // pixel shader
        "float4 MakePattern_PS(float2 IN : VPOS) : COLOR\n"
        "{\n"
        "float2 fDiv = IN / SQUARE_SIZE;\n"
        "float3 fColor = COLOR_ONE;\n"
        "if (0 == round(fmod(round(fDiv.x),2)))\n"
        "{\n"
        "  if (0 == round(fmod(round(fDiv.y),2))) fColor = COLOR_TWO;\n"
        "}\n"
        "else if (0 != round(fmod(round(fDiv.y),2)))fColor = COLOR_TWO;\n"
        "return float4(fColor,1.0f);"
        "}\n"

        // technique to generate a pattern
        "technique MakePattern\n"
        "{\n"
        "pass p0\n"
        "{\n"
        "FillMode=Solid;\n"
        "ZEnable = FALSE;\n"
        "CullMode = none;\n"
        "PixelShader = compile ps_3_0 MakePattern_PS();\n"
        "VertexShader = compile vs_3_0 DefaultVShader();\n"
        "}\n"
        "};\n");
} // namespace AssimpView