forked from doodlum/skyrim-community-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lighting.hlsl
2735 lines (2344 loc) · 102 KB
/
Lighting.hlsl
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
#include "Common/Color.hlsli"
#include "Common/FrameBuffer.hlsli"
#include "Common/GBuffer.hlsli"
#include "Common/LodLandscape.hlsli"
#include "Common/Math.hlsli"
#include "Common/MotionBlur.hlsli"
#include "Common/Permutation.hlsli"
#include "Common/Random.hlsli"
#include "Common/SharedData.hlsli"
#include "Common/Skinned.hlsli"
#if defined(FACEGEN) || defined(FACEGEN_RGB_TINT)
# define SKIN
#endif
#if defined(SKINNED) || defined(ENVMAP) || defined(EYE) || defined(MULTI_LAYER_PARALLAX)
# define DRAW_IN_WORLDSPACE
#endif
#if (defined(TREE_ANIM) || defined(LANDSCAPE)) && !defined(VC)
# define VC
#endif // TREE_ANIM || LANDSCAPE || !VC
#if defined(LODOBJECTS) || defined(LODOBJECTSHD) || defined(LODLANDNOISE) || defined(WORLD_MAP)
# define LOD
#endif
struct VS_INPUT
{
float4 Position : POSITION0;
float2 TexCoord0 : TEXCOORD0;
#if !defined(MODELSPACENORMALS)
float4 Normal : NORMAL0;
float4 Bitangent : BINORMAL0;
#endif // !MODELSPACENORMALS
#if defined(VC)
float4 Color : COLOR0;
# if defined(LANDSCAPE)
float4 LandBlendWeights1 : TEXCOORD2;
float4 LandBlendWeights2 : TEXCOORD3;
# endif // LANDSCAPE
#endif // VC
#if defined(SKINNED)
float4 BoneWeights : BLENDWEIGHT0;
float4 BoneIndices : BLENDINDICES0;
#endif // SKINNED
#if defined(EYE)
float EyeParameter : TEXCOORD2;
#endif // EYE
#if defined(VR)
uint InstanceID : SV_INSTANCEID;
#endif // VR
};
struct VS_OUTPUT
{
float4 Position : SV_POSITION0;
#if (defined(PROJECTED_UV) && !defined(SKINNED)) || defined(LANDSCAPE)
float4
#else
float2
#endif // (defined (PROJECTED_UV) && !defined(SKINNED)) || defined(LANDSCAPE)
TexCoord0 : TEXCOORD0;
#if defined(ENVMAP)
precise
#endif // ENVMAP
float3 InputPosition : TEXCOORD4;
#if defined(SKINNED) || !defined(MODELSPACENORMALS)
float3 TBN0 : TEXCOORD1;
float3 TBN1 : TEXCOORD2;
float3 TBN2 : TEXCOORD3;
#endif // defined(SKINNED) || !defined(MODELSPACENORMALS)
float3 ViewVector : TEXCOORD5;
#if defined(EYE)
float3 EyeNormal : TEXCOORD6;
#elif defined(LANDSCAPE)
float4 LandBlendWeights1 : TEXCOORD6;
float4 LandBlendWeights2 : TEXCOORD7;
#elif defined(PROJECTED_UV) && !defined(SKINNED)
float3 TexProj : TEXCOORD7;
#endif // EYE
float3 ScreenNormalTransform0 : TEXCOORD8;
float3 ScreenNormalTransform1 : TEXCOORD9;
float3 ScreenNormalTransform2 : TEXCOORD10;
// #if !defined(VR) // Position is normally not in VR, but perhaps we can use
// it.
float4 WorldPosition : POSITION1;
float4 PreviousWorldPosition : POSITION2;
// #endif // !VR
float4 Color : COLOR0;
float4 FogParam : COLOR1;
#if !defined(VR)
row_major float3x4 World[1] : POSITION3;
#else
row_major float3x4 World[2] : POSITION3;
#endif // VR
bool WorldSpace : TEXCOORD11;
#if defined(VR)
float ClipDistance : SV_ClipDistance0; // o11
float CullDistance : SV_CullDistance0; // p11
#endif
float3 ModelPosition : TEXCOORD12;
};
#ifdef VSHADER
cbuffer PerTechnique : register(b0)
{
# if !defined(VR)
float4 HighDetailRange[1] : packoffset(c0); // loaded cells center in xy, size in zw
float4 FogParam : packoffset(c1);
float4 FogNearColor : packoffset(c2);
float4 FogFarColor : packoffset(c3);
# else
float4 HighDetailRange[2] : packoffset(c0); // loaded cells center in xy, size in zw
float4 FogParam : packoffset(c2);
float4 FogNearColor : packoffset(c3);
float4 FogFarColor : packoffset(c4);
# endif // VR
};
cbuffer PerMaterial : register(b1)
{
float4 LeftEyeCenter : packoffset(c0);
float4 RightEyeCenter : packoffset(c1);
float4 TexcoordOffset : packoffset(c2);
};
cbuffer PerGeometry : register(b2)
{
# if !defined(VR)
row_major float3x4 World[1] : packoffset(c0);
row_major float3x4 PreviousWorld[1] : packoffset(c3);
float4 EyePosition[1] : packoffset(c6);
float4 LandBlendParams : packoffset(c7); // offset in xy, gridPosition in yw
float4 TreeParams : packoffset(c8); // wind magnitude in y, amplitude in z, leaf frequency in w
float2 WindTimers : packoffset(c9);
row_major float3x4 TextureProj[1] : packoffset(c10);
float IndexScale : packoffset(c13);
float4 WorldMapOverlayParameters : packoffset(c14);
# else // VR has 49 vs 30 entries
row_major float3x4 World[2] : packoffset(c0);
row_major float3x4 PreviousWorld[2] : packoffset(c6);
float4 EyePosition[2] : packoffset(c12);
float4 LandBlendParams : packoffset(c14); // offset in xy, gridPosition in yw
float4 TreeParams : packoffset(c15); // wind magnitude in y, amplitude in z, leaf frequency in w
float2 WindTimers : packoffset(c16);
row_major float3x4 TextureProj[2] : packoffset(c17);
float IndexScale : packoffset(c23);
float4 WorldMapOverlayParameters : packoffset(c24);
# endif // VR
};
cbuffer VS_PerFrame : register(b12)
{
# if !defined(VR)
row_major float3x3 ScreenProj[1] : packoffset(c0);
row_major float4x4 ViewProj[1] : packoffset(c8);
# if defined(SKINNED)
float3 BonesPivot[1] : packoffset(c40);
float3 PreviousBonesPivot[1] : packoffset(c41);
# endif // SKINNED
# else
row_major float3x3 ScreenProj[2] : packoffset(c0);
row_major float4x4 ViewProj[2] : packoffset(c16);
# if defined(SKINNED)
float3 BonesPivot[2] : packoffset(c80);
float3 PreviousBonesPivot[2] : packoffset(c82);
# endif // SKINNED
# endif // VR
};
# if defined(TREE_ANIM)
float2 GetTreeShiftVector(float4 position, float4 color)
{
precise float4 tmp1 = (TreeParams.w * TreeParams.y).xxxx * WindTimers.xxyy;
precise float4 tmp2 = float4(0.1, 0.25, 0.1, 0.25) * tmp1 + dot(position.xyz, 1.0.xxx).xxxx;
precise float4 tmp3 = abs(-1.0.xxxx + 2.0.xxxx * frac(0.5.xxxx + tmp2.xyzw));
precise float4 tmp4 = (tmp3 * tmp3) * (3.0.xxxx - 2.0.xxxx * tmp3);
return (tmp4.xz + 0.1.xx * tmp4.yw) * (TreeParams.z * color.w).xx;
}
# endif // TREE_ANIM
VS_OUTPUT main(VS_INPUT input)
{
VS_OUTPUT vsout;
precise float4 inputPosition = float4(input.Position.xyz, 1.0);
uint eyeIndex = Stereo::GetEyeIndexVS(
# if defined(VR)
input.InstanceID
# endif
);
# if defined(LODLANDNOISE) || defined(LODLANDSCAPE)
inputPosition = AdjustLodLandscapeVertexPositionMS(inputPosition, float4x4(World[eyeIndex], float4(0, 0, 0, 1)), HighDetailRange[eyeIndex]);
# endif // defined(LODLANDNOISE) || defined(LODLANDSCAPE) \
precise float4 previousInputPosition = inputPosition;
# if defined(TREE_ANIM)
precise float2 treeShiftVector = GetTreeShiftVector(input.Position, input.Color);
float3 normal = -1.0.xxx + 2.0.xxx * input.Normal.xyz;
inputPosition.xyz += normal.xyz * treeShiftVector.x;
previousInputPosition.xyz += normal.xyz * treeShiftVector.y;
# endif
# if defined(SKINNED)
precise int4 actualIndices = 765.01.xxxx * input.BoneIndices.xyzw;
float3x4 previousWorldMatrix =
GetBoneTransformMatrix(PreviousBones, actualIndices, PreviousBonesPivot[eyeIndex], input.BoneWeights);
precise float4 previousWorldPosition =
float4(mul(inputPosition, transpose(previousWorldMatrix)), 1);
float3x4 worldMatrix = GetBoneTransformMatrix(Bones, actualIndices, BonesPivot[eyeIndex], input.BoneWeights);
precise float4 worldPosition = float4(mul(inputPosition, transpose(worldMatrix)), 1);
float4 viewPos = mul(ViewProj[eyeIndex], worldPosition);
# else // !SKINNED
precise float4 previousWorldPosition = float4(mul(PreviousWorld[eyeIndex], inputPosition), 1);
precise float4 worldPosition = float4(mul(World[eyeIndex], inputPosition), 1);
precise float4x4 world4x4 = float4x4(World[eyeIndex][0], World[eyeIndex][1], World[eyeIndex][2], float4(0, 0, 0, 1));
precise float4x4 modelView = mul(ViewProj[eyeIndex], world4x4);
float4 viewPos = mul(modelView, inputPosition);
# endif // SKINNED
vsout.Position = viewPos;
# if defined(LODLANDNOISE) || defined(LODLANDSCAPE)
vsout.Position.z += min(1, 1e-4 * max(0, viewPos.z - 70000)) * 0.5;
# endif
float2 uv = input.TexCoord0.xy * TexcoordOffset.zw + TexcoordOffset.xy;
# if defined(LANDSCAPE)
vsout.TexCoord0.zw = (uv * 0.010416667.xx + LandBlendParams.xy) * float2(1, -1) + float2(0, 1);
# elif defined(PROJECTED_UV) && !defined(SKINNED)
vsout.TexCoord0.z = mul(TextureProj[eyeIndex][0], inputPosition);
vsout.TexCoord0.w = mul(TextureProj[eyeIndex][1], inputPosition);
# endif
vsout.TexCoord0.xy = uv;
# if defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX) || defined(SKINNED)
vsout.InputPosition.xyz = worldPosition.xyz;
# elif defined(WORLD_MAP)
vsout.InputPosition.xyz = WorldMapOverlayParameters.xyz + worldPosition.xyz;
# else
vsout.InputPosition.xyz = inputPosition.xyz;
# endif
# if defined(SKINNED)
float3x3 boneRSMatrix = GetBoneRSMatrix(Bones, actualIndices, input.BoneWeights);
# endif
# if !defined(MODELSPACENORMALS)
float3x3 tbn = float3x3(
float3(input.Position.w, input.Normal.w * 2 - 1, input.Bitangent.w * 2 - 1),
input.Bitangent.xyz * 2.0.xxx + -1.0.xxx,
input.Normal.xyz * 2.0.xxx + -1.0.xxx);
float3x3 tbnTr = transpose(tbn);
# if defined(SKINNED)
float3x3 worldTbnTr = transpose(mul(transpose(tbnTr), transpose(boneRSMatrix)));
float3x3 worldTbnTrTr = transpose(worldTbnTr);
worldTbnTrTr[0] = normalize(worldTbnTrTr[0]);
worldTbnTrTr[1] = normalize(worldTbnTrTr[1]);
worldTbnTrTr[2] = normalize(worldTbnTrTr[2]);
worldTbnTr = transpose(worldTbnTrTr);
vsout.TBN0.xyz = worldTbnTr[0];
vsout.TBN1.xyz = worldTbnTr[1];
vsout.TBN2.xyz = worldTbnTr[2];
# elif defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX)
vsout.TBN0.xyz = mul(tbn, World[eyeIndex][0].xyz);
vsout.TBN1.xyz = mul(tbn, World[eyeIndex][1].xyz);
vsout.TBN2.xyz = mul(tbn, World[eyeIndex][2].xyz);
float3x3 tempTbnTr = transpose(float3x3(vsout.TBN0.xyz, vsout.TBN1.xyz, vsout.TBN2.xyz));
tempTbnTr[0] = normalize(tempTbnTr[0]);
tempTbnTr[1] = normalize(tempTbnTr[1]);
tempTbnTr[2] = normalize(tempTbnTr[2]);
tempTbnTr = transpose(tempTbnTr);
vsout.TBN0.xyz = tempTbnTr[0];
vsout.TBN1.xyz = tempTbnTr[1];
vsout.TBN2.xyz = tempTbnTr[2];
# else
vsout.TBN0.xyz = tbnTr[0];
vsout.TBN1.xyz = tbnTr[1];
vsout.TBN2.xyz = tbnTr[2];
# endif
# elif defined(SKINNED)
float3x3 boneRSMatrixTr = transpose(boneRSMatrix);
float3x3 worldTbnTr = transpose(float3x3(normalize(boneRSMatrixTr[0]),
normalize(boneRSMatrixTr[1]), normalize(boneRSMatrixTr[2])));
vsout.TBN0.xyz = worldTbnTr[0];
vsout.TBN1.xyz = worldTbnTr[1];
vsout.TBN2.xyz = worldTbnTr[2];
# endif
# if defined(LANDSCAPE)
vsout.LandBlendWeights1 = input.LandBlendWeights1;
float2 gridOffset = LandBlendParams.zw - input.Position.xy;
vsout.LandBlendWeights2.w = 1 - saturate(0.000375600968 * (9625.59961 - length(gridOffset)));
vsout.LandBlendWeights2.xyz = input.LandBlendWeights2.xyz;
# elif defined(PROJECTED_UV) && !defined(SKINNED)
vsout.TexProj = TextureProj[eyeIndex][2].xyz;
# endif
# if defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX) || defined(SKINNED)
vsout.ViewVector = EyePosition[eyeIndex].xyz - worldPosition.xyz;
# else
vsout.ViewVector = EyePosition[eyeIndex].xyz - input.Position.xyz;
# endif
# if defined(EYE)
precise float4 modelEyeCenter = float4(LeftEyeCenter.xyz + input.EyeParameter.xxx * (RightEyeCenter.xyz - LeftEyeCenter.xyz), 1);
vsout.EyeNormal.xyz = normalize(worldPosition.xyz - mul(modelEyeCenter, transpose(worldMatrix)));
# endif // EYE
# if defined(SKINNED)
float3x3 ScreenNormalTransform = mul(ScreenProj[eyeIndex], worldTbnTr);
vsout.ScreenNormalTransform0.xyz = ScreenNormalTransform[0];
vsout.ScreenNormalTransform1.xyz = ScreenNormalTransform[1];
vsout.ScreenNormalTransform2.xyz = ScreenNormalTransform[2];
# else
float3x4 transMat = mul(ScreenProj[eyeIndex], World[eyeIndex]);
# if defined(MODELSPACENORMALS)
vsout.ScreenNormalTransform0.xyz = transMat[0].xyz;
vsout.ScreenNormalTransform1.xyz = transMat[1].xyz;
vsout.ScreenNormalTransform2.xyz = transMat[2].xyz;
# else
vsout.ScreenNormalTransform0.xyz = mul(transMat[0].xyz, transpose(tbn));
vsout.ScreenNormalTransform1.xyz = mul(transMat[1].xyz, transpose(tbn));
vsout.ScreenNormalTransform2.xyz = mul(transMat[2].xyz, transpose(tbn));
# endif // MODELSPACENORMALS
# endif // SKINNED
vsout.WorldPosition = worldPosition;
vsout.PreviousWorldPosition = previousWorldPosition;
# if defined(VC)
vsout.Color = input.Color;
# else
vsout.Color = 1.0.xxxx;
# endif // VC
float fogColorParam = min(FogParam.w,
exp2(FogParam.z * log2(saturate(length(viewPos.xyz) * FogParam.y - FogParam.x))));
vsout.FogParam.xyz = lerp(FogNearColor.xyz, FogFarColor.xyz, fogColorParam);
vsout.FogParam.w = fogColorParam;
vsout.World[0] = World[0];
# ifdef VR
vsout.World[1] = World[1];
# endif // VR
# if defined(SKINNED) || defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX) || defined(EYE)
vsout.WorldSpace = true;
# else
vsout.WorldSpace = false;
# endif
# if defined(VR)
Stereo::VR_OUTPUT VRout = Stereo::GetVRVSOutput(vsout.Position, eyeIndex);
vsout.Position = VRout.VRPosition;
vsout.ClipDistance.x = VRout.ClipDistance;
vsout.CullDistance.x = VRout.CullDistance;
# endif // VR
vsout.ModelPosition = input.Position.xyz;
return vsout;
}
#endif // VSHADER
typedef VS_OUTPUT PS_INPUT;
#if !defined(LANDSCAPE)
# undef TERRAIN_BLENDING
#endif
#if defined(DEFERRED)
struct PS_OUTPUT
{
float4 Diffuse : SV_Target0;
float4 MotionVectors : SV_Target1;
float4 NormalGlossiness : SV_Target2;
float4 Albedo : SV_Target3;
float4 Specular : SV_Target4;
float4 Reflectance : SV_Target5;
float4 Masks : SV_Target6;
float4 Parameters : SV_Target7;
# if defined(TERRAIN_BLENDING)
float Depth : SV_Depth;
# endif
};
#else
struct PS_OUTPUT
{
float4 Diffuse : SV_Target0;
float4 MotionVectors : SV_Target1;
float4 ScreenSpaceNormals : SV_Target2;
# if defined(SNOW)
float4 Parameters : SV_Target3;
# endif
};
#endif
#ifdef PSHADER
SamplerState SampTerrainParallaxSampler : register(s1);
# if defined(LANDSCAPE)
SamplerState SampColorSampler : register(s0);
# define SampLandColor2Sampler SampColorSampler
# define SampLandColor3Sampler SampColorSampler
# define SampLandColor4Sampler SampColorSampler
# define SampLandColor5Sampler SampColorSampler
# define SampLandColor6Sampler SampColorSampler
# define SampNormalSampler SampColorSampler
# define SampLandNormal2Sampler SampColorSampler
# define SampLandNormal3Sampler SampColorSampler
# define SampLandNormal4Sampler SampColorSampler
# define SampLandNormal5Sampler SampColorSampler
# define SampLandNormal6Sampler SampColorSampler
# define SampRMAOSSampler SampColorSampler
# define SampLandRMAOS2Sampler SampColorSampler
# define SampLandRMAOS3Sampler SampColorSampler
# define SampLandRMAOS4Sampler SampColorSampler
# define SampLandRMAOS5Sampler SampColorSampler
# define SampLandRMAOS6Sampler SampColorSampler
# else
SamplerState SampColorSampler : register(s0);
# define SampNormalSampler SampColorSampler
# if defined(MODELSPACENORMALS) && !defined(LODLANDNOISE)
SamplerState SampSpecularSampler : register(s2);
# endif
# if defined(FACEGEN)
SamplerState SampTintSampler : register(s3);
SamplerState SampDetailSampler : register(s4);
# elif defined(PARALLAX)
SamplerState SampParallaxSampler : register(s3);
# elif defined(PROJECTED_UV) && !defined(SPARKLE)
SamplerState SampProjDiffuseSampler : register(s3);
# endif
# if (defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX) || defined(SNOW_FLAG) || defined(EYE)) && !defined(FACEGEN)
SamplerState SampEnvSampler : register(s4);
SamplerState SampEnvMaskSampler : register(s5);
# endif
# if defined(TRUE_PBR)
SamplerState SampParallaxSampler : register(s4);
SamplerState SampRMAOSSampler : register(s5);
# endif
SamplerState SampGlowSampler : register(s6);
# if defined(MULTI_LAYER_PARALLAX)
SamplerState SampLayerSampler : register(s8);
# elif defined(PROJECTED_UV) && !defined(SPARKLE)
SamplerState SampProjNormalSampler : register(s8);
# endif
SamplerState SampBackLightSampler : register(s9);
# if defined(PROJECTED_UV)
SamplerState SampProjDetailSampler : register(s10);
# endif
SamplerState SampCharacterLightProjNoiseSampler : register(s11);
SamplerState SampRimSoftLightWorldMapOverlaySampler : register(s12);
# if defined(WORLD_MAP) && (defined(LODLANDSCAPE) || defined(LODLANDNOISE))
SamplerState SampWorldMapOverlaySnowSampler : register(s13);
# endif
# endif
# if defined(LOD_LAND_BLEND)
SamplerState SampLandLodBlend1Sampler : register(s13);
SamplerState SampLandLodBlend2Sampler : register(s15);
# elif defined(LODLANDNOISE)
SamplerState SampLandLodNoiseSampler : register(s15);
# endif
SamplerState SampShadowMaskSampler : register(s14);
# if defined(LANDSCAPE)
Texture2D<float4> TexColorSampler : register(t0);
Texture2D<float4> TexLandColor2Sampler : register(t1);
Texture2D<float4> TexLandColor3Sampler : register(t2);
Texture2D<float4> TexLandColor4Sampler : register(t3);
Texture2D<float4> TexLandColor5Sampler : register(t4);
Texture2D<float4> TexLandColor6Sampler : register(t5);
Texture2D<float4> TexNormalSampler : register(t7);
Texture2D<float4> TexLandNormal2Sampler : register(t8);
Texture2D<float4> TexLandNormal3Sampler : register(t9);
Texture2D<float4> TexLandNormal4Sampler : register(t10);
Texture2D<float4> TexLandNormal5Sampler : register(t11);
Texture2D<float4> TexLandNormal6Sampler : register(t12);
# if defined(TRUE_PBR)
Texture2D<float4> TexLandDisplacement0Sampler : register(t80);
Texture2D<float4> TexLandDisplacement1Sampler : register(t81);
Texture2D<float4> TexLandDisplacement2Sampler : register(t82);
Texture2D<float4> TexLandDisplacement3Sampler : register(t83);
Texture2D<float4> TexLandDisplacement4Sampler : register(t84);
Texture2D<float4> TexLandDisplacement5Sampler : register(t85);
Texture2D<float4> TexRMAOSSampler : register(t86);
Texture2D<float4> TexLandRMAOS2Sampler : register(t87);
Texture2D<float4> TexLandRMAOS3Sampler : register(t88);
Texture2D<float4> TexLandRMAOS4Sampler : register(t89);
Texture2D<float4> TexLandRMAOS5Sampler : register(t90);
Texture2D<float4> TexLandRMAOS6Sampler : register(t91);
# endif
# else
Texture2D<float4> TexColorSampler : register(t0);
Texture2D<float4> TexNormalSampler : register(t1); // normal in xyz, glossiness in w if not modelspacenormal
# if defined(MODELSPACENORMALS) && !defined(LODLANDNOISE)
Texture2D<float4> TexSpecularSampler : register(t2);
# endif
# if defined(FACEGEN)
Texture2D<float4> TexTintSampler : register(t3);
Texture2D<float4> TexDetailSampler : register(t4);
# elif defined(PARALLAX)
Texture2D<float4> TexParallaxSampler : register(t3);
# elif defined(PROJECTED_UV) && !defined(SPARKLE)
Texture2D<float4> TexProjDiffuseSampler : register(t3);
# endif
# if (defined(ENVMAP) || defined(MULTI_LAYER_PARALLAX) || defined(SNOW_FLAG) || defined(EYE)) && !defined(FACEGEN)
TextureCube<float4> TexEnvSampler : register(t4);
Texture2D<float4> TexEnvMaskSampler : register(t5);
# endif
# if defined(TRUE_PBR)
Texture2D<float4> TexParallaxSampler : register(t4);
Texture2D<float4> TexRMAOSSampler : register(t5);
# endif
Texture2D<float4> TexGlowSampler : register(t6);
# if defined(MULTI_LAYER_PARALLAX)
Texture2D<float4> TexLayerSampler : register(t8);
# elif defined(PROJECTED_UV) && !defined(SPARKLE)
Texture2D<float4> TexProjNormalSampler : register(t8);
# endif
Texture2D<float4> TexBackLightSampler : register(t9);
# if defined(PROJECTED_UV)
Texture2D<float4> TexProjDetail : register(t10);
# endif
Texture2D<float4> TexCharacterLightProjNoiseSampler : register(t11);
Texture2D<float4> TexRimSoftLightWorldMapOverlaySampler : register(t12);
# if defined(WORLD_MAP) && (defined(LODLANDSCAPE) || defined(LODLANDNOISE))
Texture2D<float4> TexWorldMapOverlaySnowSampler : register(t13);
# endif
# endif
# if defined(LOD_LAND_BLEND)
Texture2D<float4> TexLandLodBlend1Sampler : register(t13);
Texture2D<float4> TexLandLodBlend2Sampler : register(t15);
# elif defined(LODLANDNOISE)
Texture2D<float4> TexLandLodNoiseSampler : register(t15);
# endif
Texture2D<float4> TexShadowMaskSampler : register(t14);
cbuffer PerTechnique : register(b0)
{
float4 FogColor : packoffset(c0); // Color in xyz, invFrameBufferRange in w
float4 ColourOutputClamp : packoffset(c1); // fLightingOutputColourClampPostLit in x, fLightingOutputColourClampPostEnv in y, fLightingOutputColourClampPostSpec in z
float4 VPOSOffset : packoffset(c2); // ???
};
cbuffer PerMaterial : register(b1)
{
float4 LODTexParams : packoffset(c0); // TerrainTexOffset in xy, LodBlendingEnabled in z
# if !(defined(LANDSCAPE) && defined(TRUE_PBR))
float4 TintColor : packoffset(c1);
float4 EnvmapData : packoffset(c2); // fEnvmapScale in x, 1 or 0 in y depending of if has envmask
float4 ParallaxOccData : packoffset(c3);
float4 SpecularColor : packoffset(c4); // Shininess in w, color in xyz
float4 SparkleParams : packoffset(c5);
float4 MultiLayerParallaxData : packoffset(c6); // Layer thickness in x, refraction scale in y, uv scale in zw
# else
float4 LandscapeTexture1GlintParameters : packoffset(c1);
float4 LandscapeTexture2GlintParameters : packoffset(c2);
float4 LandscapeTexture3GlintParameters : packoffset(c3);
float4 LandscapeTexture4GlintParameters : packoffset(c4);
float4 LandscapeTexture5GlintParameters : packoffset(c5);
float4 LandscapeTexture6GlintParameters : packoffset(c6);
# endif
float4 LightingEffectParams : packoffset(c7); // fSubSurfaceLightRolloff in x, fRimLightPower in y
float4 IBLParams : packoffset(c8);
# if !defined(TRUE_PBR)
float4 LandscapeTexture1to4IsSnow : packoffset(c9);
float4 LandscapeTexture5to6IsSnow : packoffset(c10); // bEnableSnowMask in z, inverse iLandscapeMultiNormalTilingFactor in w
float4 LandscapeTexture1to4IsSpecPower : packoffset(c11);
float4 LandscapeTexture5to6IsSpecPower : packoffset(c12);
float4 SnowRimLightParameters : packoffset(c13); // fSnowRimLightIntensity in x, fSnowGeometrySpecPower in y, fSnowNormalSpecPower in z, bEnableSnowRimLighting in w
# endif
# if defined(TRUE_PBR) && defined(LANDSCAPE)
float3 LandscapeTexture2PBRParams : packoffset(c9);
float3 LandscapeTexture3PBRParams : packoffset(c10);
float3 LandscapeTexture4PBRParams : packoffset(c11);
float3 LandscapeTexture5PBRParams : packoffset(c12);
float3 LandscapeTexture6PBRParams : packoffset(c13);
# endif
float4 CharacterLightParams : packoffset(c14);
// VR is [9] instead of [15]
uint PBRFlags : packoffset(c15.x);
float3 PBRParams1 : packoffset(c15.y); // roughness scale, displacement scale, specular level
float4 PBRParams2 : packoffset(c16); // subsurface color, subsurface opacity
};
cbuffer PerGeometry : register(b2)
{
# if !defined(VR)
float3 DirLightDirection : packoffset(c0);
float3 DirLightColor : packoffset(c1);
float4 ShadowLightMaskSelect : packoffset(c2);
float4 MaterialData : packoffset(c3); // envmapLODFade in x, specularLODFade in y, alpha in z
float AlphaTestRef : packoffset(c4);
float3 EmitColor : packoffset(c4.y);
float4 ProjectedUVParams : packoffset(c6);
float4 SSRParams : packoffset(c7);
float4 WorldMapOverlayParametersPS : packoffset(c8);
float4 ProjectedUVParams2 : packoffset(c9);
float4 ProjectedUVParams3 : packoffset(c10); // fProjectedUVDiffuseNormalTilingScale in x, fProjectedUVNormalDetailTilingScale in y, EnableProjectedNormals in w
row_major float3x4 DirectionalAmbient : packoffset(c11);
float4 AmbientSpecularTintAndFresnelPower : packoffset(c14); // Fresnel power in z, color in xyz
float4 PointLightPosition[7] : packoffset(c15); // point light radius in w
float4 PointLightColor[7] : packoffset(c22);
float2 NumLightNumShadowLight : packoffset(c29);
# else
// VR is [49] instead of [30]
float3 DirLightDirection : packoffset(c0);
float4 UnknownPerGeometry[12] : packoffset(c1);
float3 DirLightColor : packoffset(c13);
float4 ShadowLightMaskSelect : packoffset(c14);
float4 MaterialData : packoffset(c15); // envmapLODFade in x, specularLODFade in y, alpha in z
float AlphaTestRef : packoffset(c16);
float3 EmitColor : packoffset(c16.y);
float4 ProjectedUVParams : packoffset(c18);
float4 SSRParams : packoffset(c19);
float4 WorldMapOverlayParametersPS : packoffset(c20);
float4 ProjectedUVParams2 : packoffset(c21);
float4 ProjectedUVParams3 : packoffset(c22); // fProjectedUVDiffuseNormalTilingScale in x, fProjectedUVNormalDetailTilingScale in y, EnableProjectedNormals in w
row_major float3x4 DirectionalAmbient : packoffset(c23);
float4 AmbientSpecularTintAndFresnelPower : packoffset(c26); // Fresnel power in z, color in xyz
float4 PointLightPosition[14] : packoffset(c27); // point light radius in w
float4 PointLightColor[7] : packoffset(c41);
float2 NumLightNumShadowLight : packoffset(c48);
# endif // VR
};
# if !defined(VR)
cbuffer AlphaTestRefBuffer : register(b11)
{
float AlphaTestRefRS : packoffset(c0);
}
# endif
float GetSoftLightMultiplier(float angle)
{
float softLightParam = saturate((LightingEffectParams.x + angle) / (1 + LightingEffectParams.x));
float arg1 = (softLightParam * softLightParam) * (3 - 2 * softLightParam);
float clampedAngle = saturate(angle);
float arg2 = (clampedAngle * clampedAngle) * (3 - 2 * clampedAngle);
float softLigtMul = saturate(arg1 - arg2);
return softLigtMul;
}
float GetRimLightMultiplier(float3 L, float3 V, float3 N)
{
float NdotV = saturate(dot(N, V));
return exp2(LightingEffectParams.y * log2(1 - NdotV)) * saturate(dot(V, -L));
}
# if !defined(TRUE_PBR)
float ProcessSparkleColor(float color)
{
return exp2(SparkleParams.y * log2(min(1, abs(color))));
}
# endif
float3 GetLightSpecularInput(PS_INPUT input, float3 L, float3 V, float3 N, float3 lightColor, float shininess, float2 uv)
{
float3 H = normalize(V + L);
float HdotN = 1.0;
# if defined(ANISO_LIGHTING)
float3 AN = normalize(N * 0.5 + float3(input.TBN0.z, input.TBN1.z, input.TBN2.z));
float LdotAN = dot(AN, L);
float HdotAN = dot(AN, H);
HdotN = 1 - min(1, abs(LdotAN - HdotAN));
# else
HdotN = saturate(dot(H, N));
# endif
# if defined(SPECULAR)
float lightColorMultiplier = exp2(shininess * log2(HdotN));
# elif defined(SPARKLE)
float lightColorMultiplier = 0;
# else
float lightColorMultiplier = HdotN;
# endif
# if defined(ANISO_LIGHTING)
lightColorMultiplier *= 0.7 * max(0, L.z);
# endif
# if defined(SPARKLE) && !defined(SNOW)
float3 sparkleUvScale = exp2(float3(1.3, 1.6, 1.9) * log2(abs(SparkleParams.x)).xxx);
float sparkleColor1 = TexProjDetail.Sample(SampProjDetailSampler, uv * sparkleUvScale.xx).z;
float sparkleColor2 = TexProjDetail.Sample(SampProjDetailSampler, uv * sparkleUvScale.yy).z;
float sparkleColor3 = TexProjDetail.Sample(SampProjDetailSampler, uv * sparkleUvScale.zz).z;
float sparkleColor = ProcessSparkleColor(sparkleColor1) + ProcessSparkleColor(sparkleColor2) + ProcessSparkleColor(sparkleColor3);
float VdotN = dot(V, N);
V += N * -(2 * VdotN);
float sparkleMultiplier = exp2(SparkleParams.w * log2(saturate(dot(V, -L)))) * (SparkleParams.z * sparkleColor);
sparkleMultiplier = sparkleMultiplier >= 0.5 ? 1 : 0;
lightColorMultiplier += sparkleMultiplier * HdotN;
# endif
return lightColor * lightColorMultiplier.xxx;
}
float3 TransformNormal(float3 normal)
{
return normal * 2 + -1.0.xxx;
}
float GetLodLandBlendParameter(float3 color)
{
float result = saturate(1.6666666 * (dot(color, 0.55.xxx) - 0.4));
result = ((result * result) * (3 - result * 2));
# if !defined(WORLD_MAP)
result *= 0.8;
# endif
return result;
}
float GetLodLandBlendMultiplier(float parameter, float mask)
{
return 0.8333333 * (parameter * (0.37 - mask) + mask) + 0.37;
}
float GetLandSnowMaskValue(float alpha)
{
# if !defined(TRUE_PBR)
return alpha * LandscapeTexture5to6IsSnow.z + (1 + -LandscapeTexture5to6IsSnow.z);
# else
return 0;
# endif
}
float3 GetLandNormal(float landSnowMask, float3 normal, float2 uv, SamplerState sampNormal, Texture2D<float4> texNormal)
{
float3 landNormal = TransformNormal(normal);
# if defined(SNOW) && !defined(TRUE_PBR)
if (landSnowMask > 1e-5 && LandscapeTexture5to6IsSnow.w != 1.0) {
float3 snowNormal =
float3(-1, -1, 1) *
TransformNormal(texNormal.Sample(sampNormal, LandscapeTexture5to6IsSnow.ww * uv).xyz);
landNormal.z += 1;
float normalProjection = dot(landNormal, snowNormal);
snowNormal = landNormal * normalProjection.xxx - snowNormal * landNormal.z;
return normalize(snowNormal);
} else {
return landNormal;
}
# else
return landNormal;
# endif
}
# if defined(SNOW) && !defined(TRUE_PBR)
float3 GetSnowSpecularColor(PS_INPUT input, float3 modelNormal, float3 viewDirection)
{
if (SnowRimLightParameters.w > 1e-5) {
# if defined(MODELSPACENORMALS) && !defined(SKINNED)
float3 modelGeometryNormal = float3(0, 0, 1);
# else
float3 modelGeometryNormal = normalize(float3(input.TBN0.z, input.TBN1.z, input.TBN2.z));
# endif
float normalFactor = 1 - saturate(dot(modelNormal, viewDirection));
float geometryNormalFactor = 1 - saturate(dot(modelGeometryNormal, viewDirection));
return (SnowRimLightParameters.x * (exp2(SnowRimLightParameters.y * log2(geometryNormalFactor)) * exp2(SnowRimLightParameters.z * log2(normalFactor)))).xxx;
} else {
return 0.0.xxx;
}
}
# endif
# if defined(FACEGEN)
float3 GetFacegenBaseColor(float3 rawBaseColor, float2 uv)
{
float3 detailColor = TexDetailSampler.Sample(SampDetailSampler, uv).xyz;
detailColor = float3(3.984375, 3.984375, 3.984375) * (float3(0.00392156886, 0, 0.00392156886) + detailColor);
float3 tintColor = TexTintSampler.Sample(SampTintSampler, uv).xyz;
tintColor = tintColor * rawBaseColor * 2.0.xxx;
tintColor = tintColor - tintColor * rawBaseColor;
return (rawBaseColor * rawBaseColor + tintColor) * detailColor;
}
# endif
# if defined(FACEGEN_RGB_TINT)
float3 GetFacegenRGBTintBaseColor(float3 rawBaseColor, float2 uv)
{
float3 tintColor = TintColor.xyz * rawBaseColor * 2.0.xxx;
tintColor = tintColor - tintColor * rawBaseColor;
return float3(1.01171875, 0.99609375, 1.01171875) * (rawBaseColor * rawBaseColor + tintColor);
}
# endif
# if defined(WORLD_MAP)
float3 GetWorldMapNormal(PS_INPUT input, float3 rawNormal, float3 baseColor)
{
float3 normal = normalize(rawNormal);
# if defined(MODELSPACENORMALS)
float3 worldMapNormalSrc = normal.xyz;
# else
float3 worldMapNormalSrc = float3(input.TBN0.z, input.TBN1.z, input.TBN2.z);
# endif
float3 worldMapNormal = 7.0.xxx * (-0.2.xxx + abs(normalize(worldMapNormalSrc)));
worldMapNormal = max(0.01.xxx, worldMapNormal * worldMapNormal * worldMapNormal);
worldMapNormal /= dot(worldMapNormal, 1.0.xxx);
float3 worldMapColor1 = TexRimSoftLightWorldMapOverlaySampler.Sample(SampRimSoftLightWorldMapOverlaySampler, WorldMapOverlayParametersPS.xx * input.InputPosition.yz).xyz;
float3 worldMapColor2 = TexRimSoftLightWorldMapOverlaySampler.Sample(SampRimSoftLightWorldMapOverlaySampler, WorldMapOverlayParametersPS.xx * input.InputPosition.xz).xyz;
float3 worldMapColor3 = TexRimSoftLightWorldMapOverlaySampler.Sample(SampRimSoftLightWorldMapOverlaySampler, WorldMapOverlayParametersPS.xx * input.InputPosition.xy).xyz;
# if defined(LODLANDNOISE) || defined(LODLANDSCAPE)
float3 worldMapSnowColor1 = TexWorldMapOverlaySnowSampler.Sample(SampWorldMapOverlaySnowSampler, WorldMapOverlayParametersPS.ww * input.InputPosition.yz).xyz;
float3 worldMapSnowColor2 = TexWorldMapOverlaySnowSampler.Sample(SampWorldMapOverlaySnowSampler, WorldMapOverlayParametersPS.ww * input.InputPosition.xz).xyz;
float3 worldMapSnowColor3 = TexWorldMapOverlaySnowSampler.Sample(SampWorldMapOverlaySnowSampler, WorldMapOverlayParametersPS.ww * input.InputPosition.xy).xyz;
# endif
float3 worldMapColor = worldMapNormal.xxx * worldMapColor1 + worldMapNormal.yyy * worldMapColor2 + worldMapNormal.zzz * worldMapColor3;
# if defined(LODLANDNOISE) || defined(LODLANDSCAPE)
float3 worldMapSnowColor = worldMapSnowColor1 * worldMapNormal.xxx + worldMapSnowColor2 * worldMapNormal.yyy + worldMapSnowColor3 * worldMapNormal.zzz;
float snowMultiplier = GetLodLandBlendParameter(baseColor);
worldMapColor = snowMultiplier * (worldMapSnowColor - worldMapColor) + worldMapColor;
# endif
worldMapColor = normalize(2.0.xxx * (-0.5.xxx + (worldMapColor)));
# if defined(LODLANDNOISE) || defined(LODLANDSCAPE)
float worldMapLandTmp = saturate(19.9999962 * (rawNormal.z - 0.95));
worldMapLandTmp = saturate(-(worldMapLandTmp * worldMapLandTmp) * (worldMapLandTmp * -2 + 3) + 1.5);
float3 worldMapLandTmp1 = normalize(normal.zxy * float3(1, 0, 0) - normal.yzx * float3(0, 0, 1));
float3 worldMapLandTmp2 = normalize(worldMapLandTmp1.yzx * normal.zxy - worldMapLandTmp1.zxy * normal.yzx);
float3 worldMapLandTmp3 = normalize(worldMapColor.xxx * worldMapLandTmp1 + worldMapColor.yyy * worldMapLandTmp2 + worldMapColor.zzz * normal.xyz);
float worldMapLandTmp4 = dot(worldMapLandTmp3, worldMapLandTmp3);
if (worldMapLandTmp4 > 0.999 && worldMapLandTmp4 < 1.001) {
normal.xyz = worldMapLandTmp * (worldMapLandTmp3 - normal.xyz) + normal.xyz;
}
# else
normal.xyz = normalize(
WorldMapOverlayParametersPS.zzz * (rawNormal.xyz - worldMapColor.xyz) + worldMapColor.xyz);
# endif
return normal;
}
float3 GetWorldMapBaseColor(float3 originalBaseColor, float3 rawBaseColor, float texProjTmp)
{
# if defined(LODOBJECTS) && !defined(PROJECTED_UV)
return rawBaseColor;
# endif
# if defined(LODLANDSCAPE) || defined(LODOBJECTSHD) || defined(LODLANDNOISE)
float lodMultiplier = GetLodLandBlendParameter(originalBaseColor.xyz);
# elif defined(LODOBJECTS) && defined(PROJECTED_UV)
float lodMultiplier = saturate(10 * texProjTmp);
# else
float lodMultiplier = 1;
# endif
# if defined(LODOBJECTS)
float4 lodColorMul = lodMultiplier.xxxx * float4(0.269999981, 0.281000018, 0.441000015, 0.441000015) + float4(0.0780000091, 0.09799999, -0.0349999964, 0.465000004);
float4 lodColor = lodColorMul.xyzw * 2.0.xxxx;
bool useLodColorZ = lodColorMul.w > 0.5;
lodColor.xyz = max(lodColor.xyz, rawBaseColor.xyz);
lodColor.w = useLodColorZ ? lodColor.z : min(lodColor.w, rawBaseColor.z);
return (0.5 * lodMultiplier).xxx * (lodColor.xyw - rawBaseColor.xyz) + rawBaseColor;
# else
float4 lodColorMul = lodMultiplier.xxxx * float4(0.199999988, 0.441000015, 0.269999981, 0.281000018) + float4(0.300000012, 0.465000004, 0.0780000091, 0.09799999);
float3 lodColor = lodColorMul.zwy * 2.0.xxx;
lodColor.xy = max(lodColor.xy, rawBaseColor.xy);
lodColor.z = lodColorMul.y > 0.5 ? max((lodMultiplier * 0.441 + -0.0349999964) * 2, rawBaseColor.z) : min(lodColor.z, rawBaseColor.z);
return lodColorMul.xxx * (lodColor - rawBaseColor.xyz) + rawBaseColor;
# endif
}
# endif
float GetSnowParameterY(float texProjTmp, float alpha)
{
if (PixelShaderDescriptor & LightingFlags::BaseObjectIsSnow) {
return min(1, texProjTmp + alpha);
}
return texProjTmp;
}
# if defined(LOD)
# undef EXTENDED_MATERIALS
# undef WATER_BLENDING
# undef LIGHT_LIMIT_FIX
# undef WETNESS_EFFECTS
# undef DYNAMIC_CUBEMAPS
# undef WATER_LIGHTING
# endif
# if defined(WORLD_MAP)
# undef CLOUD_SHADOWS
# undef SKYLIGHTING
# endif
# if defined(WATER_LIGHTING)
# include "WaterLighting/WaterCaustics.hlsli"
# endif
# if defined(EYE)
# undef WETNESS_EFFECTS
# endif
# if defined(EXTENDED_MATERIALS) && !defined(LOD) && (defined(PARALLAX) || defined(LANDSCAPE) || defined(ENVMAP) || defined(TRUE_PBR))
# define EMAT
# endif
# if defined(DYNAMIC_CUBEMAPS)
# include "DynamicCubemaps/DynamicCubemaps.hlsli"
# endif
# if defined(TRUE_PBR)
# include "Common/PBR.hlsli"
# endif
# if defined(EMAT)
# include "ExtendedMaterials/ExtendedMaterials.hlsli"
# endif
# if defined(SCREEN_SPACE_SHADOWS)
# include "ScreenSpaceShadows/ScreenSpaceShadows.hlsli"
# endif
# if defined(LIGHT_LIMIT_FIX)
# include "LightLimitFix/LightLimitFix.hlsli"
# endif
# if defined(TREE_ANIM)
# undef WETNESS_EFFECTS
# endif
# if defined(WETNESS_EFFECTS)
# include "WetnessEffects/WetnessEffects.hlsli"
# endif
# if defined(TERRAIN_BLENDING)
# include "TerrainBlending/TerrainBlending.hlsli"
# endif
# if defined(SSS)
# if defined(SKIN)
# undef SOFT_LIGHTING
# endif
# endif
# if defined(TERRAIN_SHADOWS)
# include "TerrainShadows/TerrainShadows.hlsli"
# endif
# if defined(CLOUD_SHADOWS)
# include "CloudShadows/CloudShadows.hlsli"
# endif
# if defined(SKYLIGHTING)
# include "Skylighting/Skylighting.hlsli"
# endif