-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathRTXGI-UE4.26.2.patch
More file actions
6945 lines (6926 loc) · 317 KB
/
Copy pathRTXGI-UE4.26.2.patch
File metadata and controls
6945 lines (6926 loc) · 317 KB
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
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/RTXGI.uplugin b/Engine/Plugins/Runtime/Nvidia/RTXGI/RTXGI.uplugin
new file mode 100644
index 00000000000..0116354bcdb
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/RTXGI.uplugin
@@ -0,0 +1,27 @@
+{
+ "FileVersion": 3,
+ "Version": 1,
+ "VersionName": "1.1.31",
+ "FriendlyName": "NVIDIA RTX Global Illumination",
+ "Description": "Real-Time Ray Traced Global Illumination",
+ "Category": "Rendering",
+ "CreatedBy": "NVIDIA",
+ "CreatedByURL": "http://developer.nvidia.com/rtxgi",
+ "DocsURL": "",
+ "MarketplaceURL": "",
+ "SupportURL": "mailto:rtxgi-support-service@nvidia.com",
+ "EnabledByDefault": false,
+ "CanContainContent": true,
+ "IsBetaVersion": false,
+ "Installed": false,
+ "Modules": [
+ {
+ "Name": "RTXGI",
+ "Type": "Runtime",
+ "LoadingPhase": "PostConfigInit",
+ "WhitelistPlatforms": [
+ "Win64"
+ ]
+ }
+ ]
+}
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ApplyLightingDeferred.usf b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ApplyLightingDeferred.usf
new file mode 100644
index 00000000000..1cc39e068c5
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ApplyLightingDeferred.usf
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#include "/Engine/Public/Platform.ush"
+#include "/Engine/Private/GammaCorrectionCommon.ush"
+
+struct DDGIVolumeDescGPU
+{
+ float3 origin;
+ float probeIrradianceEncodingGamma;
+ float4 rotation;
+ float3 probeGridSpacing;
+ float normalBias;
+ int3 probeGridCounts;
+ int probeNumIrradianceTexels;
+ int probeNumDistanceTexels;
+ float viewBias;
+ int3 probeScrollOffsets;
+};
+
+#include "/Plugin/RTXGI/Private/SDK/ddgi/Irradiance.ush"
+
+// VOLUME_LIST is defined by DDGIVolumeComponent.cpp and is a macro list like: VOLUME_ENTRY(0), VOLUME_ENTRY(1), etc
+
+Texture2D<float4> Normals;
+Texture2D<float> Depth;
+Texture2D<float4> BaseColor;
+Texture2D<float4> Metallic;
+
+SamplerState LinearClampSampler;
+
+#if USE_LIGHTING_CHANNELS
+Texture2D<uint> LightingChannelsTexture;
+#endif
+
+float4x4 ScreenToTranslatedWorld;
+float3 WorldCameraOrigin;
+float PreExposure;
+float4 InvDeviceZToWorldZTransform;
+uint ShouldUsePreExposure;
+uint NumVolumes;
+
+// generate an array of structures for each probe volume
+#define VOLUME_ENTRY(x) \
+ Texture2D<float4> DDGIVolume_##x##_ProbeIrradiance; \
+ Texture2D<float4> DDGIVolume_##x##_ProbeDistance; \
+ RWTexture2D<float4> DDGIVolume_##x##_ProbeOffsets; \
+ Texture2D<uint> DDGIVolume_##x##_ProbeStates; \
+ float3 DDGIVolume_##x##_Position; \
+ float4 DDGIVolume_##x##_Rotation; \
+ float3 DDGIVolume_##x##_Radius; \
+ float3 DDGIVolume_##x##_ProbeGridSpacing; \
+ int3 DDGIVolume_##x##_ProbeGridCounts; \
+ uint DDGIVolume_##x##_LightingChannelMask; \
+ int DDGIVolume_##x##_ProbeNumIrradianceTexels; \
+ int DDGIVolume_##x##_ProbeNumDistanceTexels; \
+ float DDGIVolume_##x##_ProbeIrradianceEncodingGamma; \
+ float DDGIVolume_##x##_NormalBias; \
+ float DDGIVolume_##x##_ViewBias; \
+ float DDGIVolume_##x##_BlendDistance; \
+ float DDGIVolume_##x##_BlendDistanceBlack; \
+ float DDGIVolume_##x##_ApplyLighting; \
+ int3 DDGIVolume_##x##_ProbeScrollOffsets; \
+ float DDGIVolume_##x##_IrradianceScalar;
+VOLUME_LIST
+#undef VOLUME_ENTRY
+
+float ConvertFromDeviceZ(float DeviceZ)
+{
+ // Supports ortho and perspective, see CreateInvDeviceZToWorldZTransform()
+ return DeviceZ * InvDeviceZToWorldZTransform[0] + InvDeviceZToWorldZTransform[1] + 1.0f / (DeviceZ * InvDeviceZToWorldZTransform[2] - InvDeviceZToWorldZTransform[3]);
+}
+
+void MainVS(
+ in uint VertexId : SV_VertexID,
+ out float4 OutPosition : SV_POSITION,
+ out float3 OutScreenVector : TEXCOORD0)
+{
+ float2 uv = float2((VertexId << 1) & 2, VertexId & 2);
+ OutPosition = float4(uv * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
+ OutScreenVector = mul(float4(OutPosition.xy, 1, 0), ScreenToTranslatedWorld).xyz;
+}
+
+bool ApplyVolumeLightingContribution(out float4 lightWeight, in Texture2D<float4> ProbeIrradiance, in Texture2D<float4> ProbeDistance, in RWTexture2D<float4> ProbeOffsets, in Texture2D<uint> ProbeStates, in float3 WorldPosition, in float3 Normal, in float3 CameraDirection,
+uint pixelLightingMask, in uint volumeLightingChannelMask, in float3 volumeRadius, in DDGIVolumeDescGPU DDGIVolume, in float3 albedo, in float BlendDistance, in float BlendDistanceBlack, in float ApplyLighting, in float IrradianceScalar)
+{
+ lightWeight = float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+ // ignore the volume if the lighting mask doesn't overlap
+ #if USE_LIGHTING_CHANNELS
+ if ((pixelLightingMask & volumeLightingChannelMask) == 0)
+ return false;
+ #endif
+
+ // ignore the volume if the pixel is outside of the volume
+ float3 relPos = WorldPosition - DDGIVolume.origin;
+ relPos = abs(RTXGIQuaternionRotate(relPos, RTXGIQuaternionConjugate(DDGIVolume.rotation)));
+ if((relPos.x > volumeRadius.x || relPos.y > volumeRadius.y || relPos.z > volumeRadius.z))
+ return false;
+
+ // fill out a DDGIVolumeResources
+ DDGIVolumeResources resources;
+ {
+ resources.probeIrradianceSRV = ProbeIrradiance;
+ resources.probeDistanceSRV = ProbeDistance;
+ resources.bilinearSampler = LinearClampSampler;
+#if RTXGI_DDGI_PROBE_RELOCATION
+ resources.probeOffsets = ProbeOffsets;
+#endif
+#if RTXGI_DDGI_PROBE_STATE_CLASSIFIER
+ resources.probeStates = ProbeStates;
+#endif
+ }
+
+ // Get irradiance from the DDGIVolume
+ if (ApplyLighting > 0.0f)
+ {
+ float3 surfaceBias = DDGIGetSurfaceBias(Normal, CameraDirection, DDGIVolume);
+ float3 irradiance = DDGIGetVolumeIrradiance(
+ WorldPosition,
+ surfaceBias,
+ Normal,
+ DDGIVolume,
+ resources
+ );
+
+ lightWeight.rgb = irradiance * (albedo / RTXGI_PI) / IrradianceScalar;
+ }
+ else
+ {
+ lightWeight.rgb = float3(0.0f, 0.0f, 0.0f);
+ }
+
+ float3 edgeDist = (volumeRadius - abs(relPos));
+ float edgeMinDist = min(edgeDist.x, min(edgeDist.y, edgeDist.z));
+ if (BlendDistance == 0.0f)
+ lightWeight.a = (edgeMinDist < BlendDistanceBlack) ? 0.0f : 1.0f;
+ else
+ lightWeight.a = clamp((edgeMinDist - BlendDistanceBlack) / BlendDistance, 0.0f, 1.0f);
+ return true;
+}
+
+void MainPS(
+ float4 SvPosition : SV_POSITION,
+ float3 InScreenVector : TEXCOORD0,
+ out float4 OutColor : SV_Target0
+ )
+{
+ int2 PixelPos = int2(SvPosition.xy);
+
+ // get information about our pixel
+ float DeviceZ = Depth.Load(int3(PixelPos, 0));
+ float SceneDepth = ConvertFromDeviceZ(DeviceZ);
+ float3 WorldPosition = InScreenVector * SceneDepth + WorldCameraOrigin;
+ float3 Normal = normalize(Normals.Load(int3(PixelPos, 0)).xyz * 2.0f - 1.0f);
+ float3 baseColor = BaseColor.Load(int3(PixelPos, 0)).rgb;
+ float metallic = Metallic.Load(int3(PixelPos, 0)).r;
+ float3 CameraDirection = normalize(InScreenVector);
+
+ float3 albedo = baseColor - baseColor * metallic;
+
+ #if USE_LIGHTING_CHANNELS
+ uint pixelLightingMask = uint(LightingChannelsTexture.Load(int3(PixelPos, 0)).x);
+ #else
+ uint pixelLightingMask = 0;
+ #endif
+
+ // Make DDGIVolumeDescGPU's. Rely on inlining and deadstripping to make this a noop.
+ #define VOLUME_ENTRY(x) \
+ DDGIVolumeDescGPU DDGIVolume_##x; \
+ DDGIVolume_##x.origin = DDGIVolume_##x##_Position; \
+ DDGIVolume_##x.rotation = DDGIVolume_##x##_Rotation; \
+ DDGIVolume_##x.probeGridSpacing = DDGIVolume_##x##_ProbeGridSpacing; \
+ DDGIVolume_##x.probeGridCounts = DDGIVolume_##x##_ProbeGridCounts; \
+ DDGIVolume_##x.probeNumIrradianceTexels = DDGIVolume_##x##_ProbeNumIrradianceTexels; \
+ DDGIVolume_##x.probeNumDistanceTexels = DDGIVolume_##x##_ProbeNumDistanceTexels; \
+ DDGIVolume_##x.probeIrradianceEncodingGamma = DDGIVolume_##x##_ProbeIrradianceEncodingGamma; \
+ DDGIVolume_##x.normalBias = DDGIVolume_##x##_NormalBias; \
+ DDGIVolume_##x.viewBias = DDGIVolume_##x##_ViewBias; \
+ DDGIVolume_##x.probeScrollOffsets = DDGIVolume_##x##_ProbeScrollOffsets;
+ VOLUME_LIST
+ #undef VOLUME_ENTRY
+
+ // NOTE: if wanting to visualize / debug the blend, it's useful to hard code some colors temporarily.
+ // like have volume zero be red, and volume one be yellow
+
+ // Gather up to 2 lighting contributions
+ float4 primaryLightWeight = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float4 secondaryLightWeight = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ float4 lightWeight = float4(0.0f, 0.0f, 0.0f, 0.0f);
+ #define VOLUME_ENTRY(x) \
+ if (x < NumVolumes && primaryLightWeight.a < 1.0f && secondaryLightWeight.a == 0.0f && ApplyVolumeLightingContribution(lightWeight, DDGIVolume_##x##_ProbeIrradiance, DDGIVolume_##x##_ProbeDistance, DDGIVolume_##x##_ProbeOffsets, DDGIVolume_##x##_ProbeStates, WorldPosition, Normal, CameraDirection, pixelLightingMask, \
+ uint(DDGIVolume_##x##_LightingChannelMask), DDGIVolume_##x##_Radius, DDGIVolume_##x, albedo, DDGIVolume_##x##_BlendDistance, DDGIVolume_##x##_BlendDistanceBlack, DDGIVolume_##x##_ApplyLighting, DDGIVolume_##x##_IrradianceScalar)) \
+ { \
+ if (primaryLightWeight.a == 0.0f) \
+ primaryLightWeight = lightWeight; \
+ else \
+ secondaryLightWeight = lightWeight; \
+ }
+ VOLUME_LIST
+ #undef VOLUME_ENTRY
+
+ float preExposure = ShouldUsePreExposure ? PreExposure : 1.0f;
+
+ // Explanation of the statements below
+ // 1) If the pixel is not inside of any volume, return black.
+ // 2) If the pixel is inside of 1 volume, we want to fade it out by multiplying the primaryLightWeight color by the weight.
+ // 3) If we are in the non fade region of the primary volume, just use that color.
+ // 4) if we are in the fade region of both volumes, do something that preserves luminance of fade, since the color is going to be real similar anyways (this is the case for the max usage)
+ if (primaryLightWeight.a == 0.0f || secondaryLightWeight.a == 0.0f || primaryLightWeight.a == 1.0f || secondaryLightWeight.a < 1.0f)
+ {
+ OutColor = float4(primaryLightWeight.rgb * max(primaryLightWeight.a, secondaryLightWeight.a) * preExposure, 1.0f);
+ }
+ // else we are in the fade region of the primary volume, but not the fade region of the secondary volume, so blend between primary and secondary
+ else
+ {
+ OutColor = float4(lerp(secondaryLightWeight.rgb, primaryLightWeight.rgb, primaryLightWeight.a) * preExposure, 1.0f);
+ }
+}
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeUpdateRGS.usf b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeUpdateRGS.usf
new file mode 100644
index 00000000000..0efd944cd7e
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeUpdateRGS.usf
@@ -0,0 +1,315 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#include "/Engine/Private/HairStrands/HairStrandsVoxelPageCommonStruct.ush"
+#include "/Engine/Private/Common.ush"
+
+struct DDGIVolumeDescGPU
+{
+ float3 origin;
+ int numRaysPerProbe;
+ float4 rotation;
+ float3 probeGridSpacing;
+ float probeMaxRayDistance;
+ int3 probeGridCounts;
+ float4x4 probeRayRotationTransform;
+ float normalBias;
+ float viewBias;
+ float probeNumIrradianceTexels;
+ float probeNumDistanceTexels;
+ float probeIrradianceEncodingGamma;
+ int3 probeScrollOffsets;
+};
+
+// RTXGI SDK
+#include "/Plugin/RTXGI/Private/SDK/ddgi/Irradiance.ush"
+
+// needed by DeferredLightingCommon included indirectly
+#define SUPPORT_CONTACT_SHADOWS 0
+
+// from RayTracingPrimaryRays.usf - see that .cpp for how to pass all these params properly
+#define LTCMatTexture RaytracingLightsDataPacked.LTCMatTexture
+#define LTCMatSampler RaytracingLightsDataPacked.LTCMatSampler
+#define LTCAmpTexture RaytracingLightsDataPacked.LTCAmpTexture
+#define LTCAmpSampler RaytracingLightsDataPacked.LTCAmpSampler
+#define PreIntegratedGF ReflectionStruct.PreIntegratedGF
+#define PreIntegratedGFSampler ReflectionStruct.PreIntegratedGFSampler
+
+#include "/Engine/Private/DeferredLightingCommon.ush"
+#include "/Engine/Private/DeferredShadingCommon.ush"
+#include "/Engine/Private/PathTracing/Utilities/PathTracingRandomSequence.ush"
+#include "/Engine/Private/SceneTextureParameters.ush"
+#include "/Engine/Private/RayTracing/RayTracingCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingDeferredShadingCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingHitGroupCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingDirectionalLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingRectLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingSphereLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingSpotLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingPointLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingLightingCommon.ush"
+#include "/Engine/Private/ReflectionEnvironmentShared.ush"
+#include "/Engine/Private/Montecarlo.ush"
+#include "/Engine/Private/HeightFogCommon.ush"
+#include "/Engine/Private/SobolRandom.ush"
+
+// START RGS PARAMS
+RaytracingAccelerationStructure TLAS;
+
+RWTexture2D<float4> RadianceOutput;
+RWTexture2D<float4> DebugOutput;
+
+uint FrameRandomSeed;
+
+Texture2D<float4> DDGIVolume_ProbeIrradiance;
+Texture2D<float4> DDGIVolume_ProbeDistance;
+RWTexture2D<float4> DDGIVolume_ProbeOffsets;
+Texture2D<uint> DDGIVolume_ProbeStates;
+float3 DDGIVolume_Origin;
+float4 DDGIVolume_Rotation;
+float3 DDGIVolume_ProbeGridSpacing;
+float DDGIVolume_ProbeMaxRayDistance;
+int3 DDGIVolume_ProbeGridCounts;
+float4x4 DDGIVolume_ProbeRayRotationTransform;
+int DDGIVolume_NumRaysPerProbe;
+float3 DDGIVolume_Radius;
+int DDGIVolume_ProbeNumIrradianceTexels;
+int DDGIVolume_ProbeNumDistanceTexels;
+float DDGIVolume_ProbeIrradianceEncodingGamma;
+float DDGIVolume_NormalBias;
+float DDGIVolume_ViewBias;
+SamplerState DDGIVolume_LinearClampSampler;
+int3 DDGIVolume_ProbeScrollOffsets;
+float DDGIVolume_IrradianceScalar;
+int DDGIVolume_ProbeIndexStart;
+int DDGIVolume_ProbeIndexCount;
+float DDGIVolume_EmissiveMultiplier;
+
+float3 Sky_Color;
+TextureCube<float4> Sky_Texture;
+SamplerState Sky_TextureSampler;
+
+// END RGS PARAMS
+
+float3 GetEnvironmentalRadiance(in float3 direction)
+{
+ return Sky_Color * TextureCubeSampleLevel(Sky_Texture, Sky_TextureSampler, direction, 0).rgb;
+}
+
+void WriteRadianceOutput(uint2 DispatchIndex, float4 value)
+{
+#if !RTXGI_DDGI_DEBUG_FORMAT_RADIANCE
+ static const float c_threshold = 1.f / 255.f;
+ if (RTXGIMaxComponent(value.rgb) <= c_threshold) value.rgb = float3(0.f, 0.f, 0.f);
+#endif
+
+ // Radiance / irradiance is multipled by this when stored, but divided by this when recalled.
+ // This feature is to avoid clipping when using the 10 bit texture format.
+ value.rgb *= DDGIVolume_IrradianceScalar;
+
+#if RTXGI_DDGI_DEBUG_FORMAT_RADIANCE
+ // Use R32G32B32A32_FLOAT format. Store color components and hit distance as 32-bit float values.
+ RadianceOutput[DispatchIndex.xy] = value;
+#else
+ // Use R32G32_FLOAT format (don't use R32G32_UINT since hit distance needs to be negative sometimes).
+ // Pack color as R10G10B10 in R32 and store hit distance in G32.
+ RadianceOutput[DispatchIndex.xy] = float4(asfloat(RTXGIFloat3ToUint(clamp(value.rgb, 0.0f, 1.0f))), value.w, 0.f, 0.f);
+#endif
+
+#if DDGIVolumeUpdateDebug != 0
+ DebugOutput[DispatchIndex.xy] = value;
+#endif
+}
+
+RAY_TRACING_ENTRY_RAYGEN(ProbeUpdateRGS)
+{
+ DDGIVolumeDescGPU DDGIVolume;
+ DDGIVolume.origin = DDGIVolume_Origin;
+ DDGIVolume.numRaysPerProbe = DDGIVolume_NumRaysPerProbe;
+ DDGIVolume.rotation = DDGIVolume_Rotation;
+ DDGIVolume.probeGridSpacing = DDGIVolume_ProbeGridSpacing;
+ DDGIVolume.probeMaxRayDistance = DDGIVolume_ProbeMaxRayDistance;
+ DDGIVolume.probeGridCounts = DDGIVolume_ProbeGridCounts;
+ DDGIVolume.probeRayRotationTransform = DDGIVolume_ProbeRayRotationTransform;
+ DDGIVolume.normalBias = DDGIVolume_NormalBias;
+ DDGIVolume.viewBias = DDGIVolume_ViewBias;
+ DDGIVolume.probeNumIrradianceTexels = DDGIVolume_ProbeNumIrradianceTexels;
+ DDGIVolume.probeNumDistanceTexels = DDGIVolume_ProbeNumDistanceTexels;
+ DDGIVolume.probeIrradianceEncodingGamma = DDGIVolume_ProbeIrradianceEncodingGamma;
+ DDGIVolume.probeScrollOffsets = DDGIVolume_ProbeScrollOffsets;
+
+ // Adapted from ProbeTraceRGS.hlsl in the test harness aiming for minimal changes to help future merges.
+
+ float4 result = 0.f;
+
+ uint2 DispatchIndex = DispatchRaysIndex().xy;
+ int rayIndex = DispatchIndex.x; // index of ray within a probe
+ int probeIndex = DispatchIndex.y; // index of current probe
+
+ // Handle round robin updating.
+ // If this probe is outside of the window for updating, bail out.
+ {
+ int numProbes = DDGIVolume_ProbeGridCounts.x * DDGIVolume_ProbeGridCounts.y * DDGIVolume_ProbeGridCounts.z;
+ int probeRRIndex = (probeIndex < DDGIVolume_ProbeIndexStart) ? probeIndex + numProbes : probeIndex;
+ if (probeRRIndex >= DDGIVolume_ProbeIndexStart + DDGIVolume_ProbeIndexCount)
+ return;
+ }
+
+#if RTXGI_DDGI_PROBE_STATE_CLASSIFIER
+#if RTXGI_DDGI_PROBE_SCROLL
+ int storageProbeIndex = DDGIGetProbeIndexOffset(probeIndex, DDGIVolume.probeGridCounts, DDGIVolume.probeScrollOffsets);
+#else
+ int storageProbeIndex = probeIndex;
+#endif
+ int2 texelPosition = DDGIGetProbeTexelPosition(storageProbeIndex, DDGIVolume.probeGridCounts);
+ int probeState = DDGIVolume_ProbeStates.Load(int3(texelPosition, 0));
+ if (probeState == PROBE_STATE_INACTIVE && rayIndex >= RTXGI_DDGI_NUM_FIXED_RAYS)
+ {
+ // if the probe is inactive, do not shoot rays, unless it is one of the fixed rays that could potentially reactivate the probe
+ return;
+ }
+#endif
+
+#if RTXGI_DDGI_PROBE_RELOCATION
+ #if RTXGI_DDGI_PROBE_SCROLL
+ float3 probeWorldPosition = DDGIGetProbeWorldPositionWithOffset(probeIndex, DDGIVolume.origin, DDGIVolume.rotation, DDGIVolume.probeGridCounts, DDGIVolume.probeGridSpacing, DDGIVolume.probeScrollOffsets, DDGIVolume_ProbeOffsets);
+ #else
+ float3 probeWorldPosition = DDGIGetProbeWorldPositionWithOffset(probeIndex, DDGIVolume.origin, DDGIVolume.rotation, DDGIVolume.probeGridCounts, DDGIVolume.probeGridSpacing, DDGIVolume_ProbeOffsets);
+ #endif
+#else
+ float3 probeWorldPosition = DDGIGetProbeWorldPosition(probeIndex, DDGIVolume.origin, DDGIVolume.rotation, DDGIVolume.probeGridCounts, DDGIVolume.probeGridSpacing);
+#endif
+
+ float3 probeRayDirection = DDGIGetProbeRayDirection(rayIndex, DDGIVolume.numRaysPerProbe, DDGIVolume.probeRayRotationTransform);
+
+ // Setup the probe ray
+ RayDesc Ray;
+ Ray.Origin = probeWorldPosition;
+ Ray.Direction = probeRayDirection;
+ Ray.TMin = 0.f;
+ Ray.TMax = DDGIVolume.probeMaxRayDistance;
+
+ const int ReflectedShadowsType = 1; // = hard shadows. make configurable?
+ const uint RefractionRayFlags = 0;
+ const uint RefractionInstanceInclusionMask = RAY_TRACING_MASK_ALL;
+
+ #if DDGI_SKYLIGHT
+ const bool bRefractionEnableSkyLightContribution = true;
+ #else
+ const bool bRefractionEnableSkyLightContribution = false;
+ #endif
+
+ const bool bRefractionRayTraceSkyLightContribution = false;
+ const bool bRefractionDecoupleSampleGeneration = true;
+ const bool ShouldDoDirectLighting = true;
+ const bool ShouldDoEmissiveAndIndirectLighting = true;
+ float3 PathVertexRadiance = float3(0, 0, 0);
+ FRayCone RayCone = (FRayCone)0;
+ float MaxNormalBias = 0.01f;
+
+ // Trace
+ uint linear_rand = DispatchIndex.x + DispatchIndex.y * 9973;
+ RandomSequence RandSequence;
+ RandomSequence_Initialize(RandSequence, linear_rand, FrameRandomSeed);
+ uint2 PixelCoord = DispatchRaysIndex().xy; // Hmmmm.... does TraceRayAndAccumulateResults() assume screen-space trace or is this just for stochastics? hopefully the latter but fixme:checkme
+
+ FMaterialClosestHitPayload Payload = TraceRayAndAccumulateResults(
+ Ray,
+ TLAS,
+ RefractionRayFlags,
+ RefractionInstanceInclusionMask,
+ RandSequence,
+ PixelCoord,
+ MaxNormalBias,
+ ReflectedShadowsType,
+ ShouldDoDirectLighting,
+ ShouldDoEmissiveAndIndirectLighting,
+ bRefractionRayTraceSkyLightContribution,
+ bRefractionDecoupleSampleGeneration,
+ RayCone,
+ bRefractionEnableSkyLightContribution,
+ PathVertexRadiance);
+
+ // Adjust emissive contribution if we should
+ PathVertexRadiance += Payload.Radiance * (DDGIVolume_EmissiveMultiplier - 1.0f);
+
+ result = float4(PathVertexRadiance.xyz, Payload.HitT);
+
+ // Ray miss. Set hit distance to a large value and exit early.
+ if (Payload.IsMiss())
+ {
+ result.rgb += GetEnvironmentalRadiance(Ray.Direction);
+ result.w = 1e27f;
+ WriteRadianceOutput(DispatchIndex.xy, result);
+ return;
+ }
+
+ // Hit a surface backface. Set the radiance to black and exit early.
+ if (!Payload.IsFrontFace() && Payload.ShadingModelID != SHADINGMODELID_TWOSIDED_FOLIAGE)
+ {
+ // Shorten the hit distance on a backface hit by 80%
+ // Make distance negative to encode backface for the probe position preprocess.
+ WriteRadianceOutput(DispatchIndex.xy, float4(0.0f, 0.0f, 0.0f, -Payload.HitT * 0.2f));
+ return;
+ }
+
+#if RTXGI_DDGI_PROBE_STATE_CLASSIFIER
+ // hit a frontface, but probe is inactive, so this ray will only be used for reclassification, don't need any lighting
+ if (probeState == PROBE_STATE_INACTIVE)
+ {
+ WriteRadianceOutput(DispatchIndex.xy, float4(0.0f, 0.0f, 0.0f, Payload.HitT));
+ return;
+ }
+#endif
+
+ float3 probeLighting = float3(0.0f, 0.0f, 0.0f);
+ {
+ float3 albedo = Payload.BaseColor - Payload.BaseColor * Payload.Metallic;
+
+ // fill out a DDGIVolumeResources
+ DDGIVolumeResources resources;
+ {
+ resources.probeIrradianceSRV = DDGIVolume_ProbeIrradiance;
+ resources.probeDistanceSRV = DDGIVolume_ProbeDistance;
+ resources.bilinearSampler = DDGIVolume_LinearClampSampler;
+#if RTXGI_DDGI_PROBE_RELOCATION
+ resources.probeOffsets = DDGIVolume_ProbeOffsets;
+#endif
+#if RTXGI_DDGI_PROBE_STATE_CLASSIFIER
+ resources.probeStates = DDGIVolume_ProbeStates;
+#endif
+ }
+
+ // Get irradiance from the DDGIVolume
+ float3 surfacePosWS = Ray.Origin + Ray.Direction * Payload.HitT;
+ float3 surfaceBias = DDGIGetSurfaceBias(Payload.WorldNormal, Ray.Direction, DDGIVolume);
+ float3 irradiance = DDGIGetVolumeIrradiance(
+ surfacePosWS,
+ surfaceBias,
+ Payload.WorldNormal,
+ DDGIVolume,
+ resources
+ );
+
+ // Perfectly diffuse reflectors don't exist in the real world. Limit the BRDF
+ // albedo to a maximum value to account for the energy loss at each bounce.
+ float maxAlbedo = 0.9f;
+
+ probeLighting = irradiance * (min(albedo, maxAlbedo) / RTXGI_PI);
+ probeLighting /= DDGIVolume_IrradianceScalar;
+
+ // don't apply volume lighting outside the volume
+ float3 relPos = abs(surfacePosWS - DDGIVolume_Origin);
+ if((relPos.x > DDGIVolume_Radius.x || relPos.y > DDGIVolume_Radius.y || relPos.z > DDGIVolume_Radius.z))
+ probeLighting = float3(0.0f, 0.0f, 0.0f);
+ }
+
+ WriteRadianceOutput(DispatchIndex.xy, float4(PathVertexRadiance.xyz + probeLighting, Payload.HitT));
+}
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeViewRGS.usf b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeViewRGS.usf
new file mode 100644
index 00000000000..95a0cf4c1a8
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/ProbeViewRGS.usf
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+/*
+This shader shoots a viewport of rays so you can see what the volume sees, copying the logic of ProbeUpdateRGS.usf.
+
+r.RTXGI.DDGIProbeVis 0 - turn it off
+r.RTXGI.DDGIProbeVis 1 - render the scene color. (VOLUME_DEBUG_VIEW == 0)
+r.RTXGI.DDGIProbeVis 2 - render misses (blue), hits (green), back face hits (red). (VOLUME_DEBUG_VIEW == 1)
+
+then "vis DDGIProbeVis" to see the texture
+*/
+
+#include "/Engine/Private/HairStrands/HairStrandsVoxelPageCommonStruct.ush"
+#include "/Engine/Private/Common.ush"
+
+// needed by DeferredLightingCommon included indirectly
+#define SUPPORT_CONTACT_SHADOWS 0
+
+//macro to deal with parameter not used by miss shaders
+#define OcclusionCullDirection 0
+
+// from RayTracingPrimaryRays.usf - see that .cpp for how to pass all these params properly
+#define LTCMatTexture RaytracingLightsDataPacked.LTCMatTexture
+#define LTCMatSampler RaytracingLightsDataPacked.LTCMatSampler
+#define LTCAmpTexture RaytracingLightsDataPacked.LTCAmpTexture
+#define LTCAmpSampler RaytracingLightsDataPacked.LTCAmpSampler
+#define PreIntegratedGF ReflectionStruct.PreIntegratedGF
+#define PreIntegratedGFSampler ReflectionStruct.PreIntegratedGFSampler
+
+#include "/Engine/Private/DeferredLightingCommon.ush"
+#include "/Engine/Private/DeferredShadingCommon.ush"
+#include "/Engine/Private/PathTracing/Utilities/PathTracingRandomSequence.ush"
+#include "/Engine/Private/SceneTextureParameters.ush"
+#include "/Engine/Private/RayTracing/RayTracingCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingDeferredShadingCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingHitGroupCommon.ush"
+#include "/Engine/Private/RayTracing/RayTracingDirectionalLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingRectLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingSphereLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingSpotLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingPointLight.ush"
+#include "/Engine/Private/RayTracing/RayTracingLightingCommon.ush"
+#include "/Engine/Private/ReflectionEnvironmentShared.ush"
+#include "/Engine/Private/Montecarlo.ush"
+#include "/Engine/Private/HeightFogCommon.ush"
+#include "/Engine/Private/SobolRandom.ush"
+
+// START RGS PARAMS
+RaytracingAccelerationStructure TLAS;
+
+uint FrameRandomSeed;
+
+float3 CameraPos;
+float4x4 CameraMatrix;
+
+float DDGIVolume_PreExposure;
+uint DDGIVolume_ShouldUsePreExposure;
+
+float3 Sky_Color;
+TextureCube<float4> Sky_Texture;
+SamplerState Sky_TextureSampler;
+
+RWTexture2D<float4> RadianceOutput;
+
+// END RGS PARAMS
+
+float3 GetEnvironmentalRadiance(in float3 direction)
+{
+ return Sky_Color * TextureCubeSampleLevel(Sky_Texture, Sky_TextureSampler, direction, 0).rgb;
+}
+
+// This should match the logic of ProbeUpdateRGS above, for best results.
+// It isn't sampling DDGI volumes though so is only direct lighting.
+RAY_TRACING_ENTRY_RAYGEN(ProbeViewRGS)
+{
+ uint2 DispatchIndex = DispatchRaysIndex().xy;
+
+ // This is to make the radiance be in a viewable range
+ float radianceMultiplier = DDGIVolume_ShouldUsePreExposure ? DDGIVolume_PreExposure : 1.0f;
+
+ RayDesc Ray;
+ Ray.Origin = CameraPos;
+ float3 rayTarget = float3(float2(DispatchIndex.xy) / float2(DispatchRaysDimensions().xy) * 2.0f - 1.0f, 1.0f);
+ rayTarget.y *= -1.0f;
+ float3 rayDir = mul(float4(normalize(rayTarget), 0.0f), CameraMatrix).xyz;
+ Ray.Direction = rayDir;
+ Ray.TMin = 0.f;
+ Ray.TMax = 10000.0f;
+
+ const int ReflectedShadowsType = 1; // = hard shadows. make configurable?
+ const uint RefractionRayFlags = 0;
+ const uint RefractionInstanceInclusionMask = RAY_TRACING_MASK_ALL;
+ const bool bRefractionRayTraceSkyLightContribution = false;
+ const bool bRefractionDecoupleSampleGeneration = true;
+ const bool bRefractionEnableSkyLightContribution = true;
+ const bool ShouldDoDirectLighting = true;
+ const bool ShouldDoEmissiveAndIndirectLighting = true;
+ float3 PathVertexRadiance = float3(0, 0, 0);
+ FRayCone RayCone = (FRayCone)0;
+ float MaxNormalBias = 0.01f;
+
+ // Trace
+ uint linear_rand = DispatchIndex.x + DispatchIndex.y * 9973;
+ RandomSequence RandSequence;
+ RandomSequence_Initialize(RandSequence, linear_rand, FrameRandomSeed);
+ uint2 PixelCoord = DispatchRaysIndex().xy;
+
+ FMaterialClosestHitPayload Payload;
+ //Payload.SetEnableSkyLightContribution();
+
+ Payload = TraceRayAndAccumulateResults(
+ Ray,
+ TLAS,
+ RefractionRayFlags,
+ RefractionInstanceInclusionMask,
+ RandSequence,
+ PixelCoord,
+ MaxNormalBias,
+ ReflectedShadowsType,
+ ShouldDoDirectLighting,
+ ShouldDoEmissiveAndIndirectLighting,
+ bRefractionRayTraceSkyLightContribution,
+ bRefractionDecoupleSampleGeneration,
+ RayCone,
+ bRefractionEnableSkyLightContribution,
+ PathVertexRadiance);
+
+ float4 result = float4(PathVertexRadiance.xyz, Payload.HitT);
+
+ // show ray miss / hit / back face hit
+ #if VOLUME_DEBUG_VIEW == 1
+ {
+ if (Payload.IsMiss())
+ {
+ RadianceOutput[DispatchIndex.xy] = float4(0.0f, 0.0f, 100.0f, 1e27f);
+ }
+ else
+ {
+ if (Payload.IsFrontFace() || Payload.ShadingModelID == SHADINGMODELID_TWOSIDED_FOLIAGE)
+ RadianceOutput[DispatchIndex.xy] = float4(0.0f, 100.0f, 0.0f, Payload.HitT);
+ else
+ RadianceOutput[DispatchIndex.xy] = float4(100.0f, 0.0f, 0.0f, Payload.HitT);
+ }
+ return;
+ }
+ #endif
+
+ // Ray miss. Set hit distance to a large value and exit early.
+ if (Payload.IsMiss())
+ {
+ result.rgb += GetEnvironmentalRadiance(Ray.Direction);
+ result.rgb *= radianceMultiplier;
+
+ result.w = 1e27f;
+ RadianceOutput[DispatchIndex.xy] = result;
+ return;
+ }
+
+ // Hit a surface backface. Set the radiance to black and exit early.
+ if (!Payload.IsFrontFace() && Payload.ShadingModelID != SHADINGMODELID_TWOSIDED_FOLIAGE)
+ {
+ // Shorten the hit distance on a backface hit by 20%
+ // Make distance negative to encode backface for the probe position preprocess.
+ RadianceOutput[DispatchIndex.xy] = float4(0.f, 0.f, 0.f, -Payload.HitT * 0.2f);
+ return;
+ }
+
+ RadianceOutput[DispatchIndex.xy] = float4(PathVertexRadiance.xyz * radianceMultiplier, Payload.HitT);
+}
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/Common.ush b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/Common.ush
new file mode 100644
index 00000000000..4ebc9339243
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/Common.ush
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef RTXGI_COMMON_HLSL
+#define RTXGI_COMMON_HLSL
+
+static const float RTXGI_PI = 3.1415926535897932f;
+static const float RTXGI_2PI = 6.2831853071795864f;
+
+//------------------------------------------------------------------------
+// Math Helpers
+//------------------------------------------------------------------------
+
+/**
+* Finds the largest component of the vector.
+*/
+float RTXGIMaxComponent(float3 a)
+{
+ return max(a.x, max(a.y, a.z));
+}
+
+/**
+* Returns either -1 or 1 based on the sign of the input value.
+* If the input is zero, 1 is returned.
+*/
+float RTXGISignNotZero(float v)
+{
+ return (v >= 0.f) ? 1.f : -1.f;
+}
+
+/**
+* 2-component version of RTXGISignNotZero.
+*/
+float2 RTXGISignNotZero(float2 v)
+{
+ return float2(RTXGISignNotZero(v.x), RTXGISignNotZero(v.y));
+}
+
+/**
+* Return the given float value as an unsigned integer within the given numerical scale.
+*/
+uint RTXGIFloatToUint(float v, float scale)
+{
+ return (uint)floor(v * scale + 0.5f);
+}
+
+/**
+* Pack a float3 into a 32-bit unsigned integer.
+* All channels use 10 bits and 2 bits are unused.
+* Compliment of RTXGIUintToFloat3().
+*/
+uint RTXGIFloat3ToUint(float3 input)
+{
+ return (RTXGIFloatToUint(input.r, 1023.f)) | (RTXGIFloatToUint(input.g, 1023.f) << 10) | (RTXGIFloatToUint(input.b, 1023.f) << 20);
+}
+
+/**
+* Unpack a packed 32-bit unsigned integer to a float3.
+* Compliment of RTXGIFloat3ToUint().
+*/
+float3 RTXGIUintToFloat3(uint input)
+{
+ float3 unpacked;
+ unpacked.x = (float)(input & 0x000003FF) / 1023.f;
+ unpacked.y = (float)((input >> 10) & 0x000003FF) / 1023.f;
+ unpacked.z = (float)((input >> 20) & 0x000003FF) / 1023.f;
+ return unpacked;
+}
+
+/**
+* Rotate vector v with quaternion q.
+*/
+float3 RTXGIQuaternionRotate(float3 v, float4 q)
+{
+ float3 b = q.xyz;
+ float b2 = dot(b, b);
+ return (v * (q.w * q.w - b2) + b * (dot(v, b) * 2.f) + cross(b, v) * (q.w * 2.f));
+}
+
+/**
+* Quaternion conjugate.
+* For unit quaternions, conjugate equals inverse.
+* Use this to create a quaternion that rotates in the opposite direction.
+*/
+float4 RTXGIQuaternionConjugate(float4 q)
+{
+ return float4(-q.xyz, q.w);
+}
+
+#endif /* RTXGI_COMMON_HLSL */
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/DDGIVolumeDefines.ush b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/DDGIVolumeDefines.ush
new file mode 100644
index 00000000000..da4d07575d1
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/DDGIVolumeDefines.ush
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef RTXGI_DDGI_VOLUME_DEFINES_H
+#define RTXGI_DDGI_VOLUME_DEFINES_H
+
+// --- Resources -------------------------------------
+
+#ifndef RTXGI_DDGI_SDK_MANAGED_RESOURCES
+#define RTXGI_DDGI_SDK_MANAGED_RESOURCES 0
+#endif
+
+// low bit depth irradiance will set this to 0 for shaders, high bit depth will set it to 1.
+/*
+#ifndef RTXGI_DDGI_DEBUG_FORMAT_RADIANCE
+#define RTXGI_DDGI_DEBUG_FORMAT_RADIANCE 0
+#endif
+
+#ifndef RTXGI_DDGI_DEBUG_FORMAT_IRRADIANCE
+#define RTXGI_DDGI_DEBUG_FORMAT_IRRADIANCE 0
+#endif
+
+#ifndef RTXGI_DDGI_DEBUG_FORMAT_DISTANCE
+#define RTXGI_DDGI_DEBUG_FORMAT_DISTANCE 0
+#endif
+*/
+
+#ifndef RTXGI_DDGI_DEBUG_FORMAT_OFFSETS
+#define RTXGI_DDGI_DEBUG_FORMAT_OFFSETS 0
+#endif
+
+// --- Probe Update ----------------------------------
+
+#ifndef RTXGI_DDGI_BLENDING_USE_SHARED_MEMORY
+#define RTXGI_DDGI_BLENDING_USE_SHARED_MEMORY 1
+#endif
+
+#ifndef RTXGI_DDGI_DEBUG_PROBE_INDEXING
+#define RTXGI_DDGI_DEBUG_PROBE_INDEXING 0
+#endif
+
+#ifndef RTXGI_DDGI_DEBUG_OCTAHEDRAL_INDEXING
+#define RTXGI_DDGI_DEBUG_OCTAHEDRAL_INDEXING 0
+#endif
+
+#ifndef RTXGI_DDGI_DEBUG_BORDER_COPY_INDEXING
+#define RTXGI_DDGI_DEBUG_BORDER_COPY_INDEXING 0
+#endif
+
+// --- Indirect Lighting -----------------------------
+
+#ifndef RTXGI_DDGI_COMPUTE_IRRADIANCE
+#define RTXGI_DDGI_COMPUTE_IRRADIANCE 1
+#endif
+
+#ifndef RTXGI_DDGI_COMPUTE_IRRADIANCE_RECURSIVE
+#define RTXGI_DDGI_COMPUTE_IRRADIANCE_RECURSIVE 1
+#endif
+
+// --- Probe Relocation -------------------------
+
+// a per volume setting, so a shader permutation
+/*
+#ifndef RTXGI_DDGI_PROBE_RELOCATION
+#define RTXGI_DDGI_PROBE_RELOCATION 0
+#endif
+*/
+
+// --- Probe Classification -------------------------
+
+// always on, but defined to be 1 in code
+/*
+#ifndef RTXGI_DDGI_PROBE_STATE_CLASSIFIER
+#define RTXGI_DDGI_PROBE_STATE_CLASSIFIER 0
+#endif
+*/
+
+// --- Probe Movement (Early Access) --------------------------------
+
+// a per volume setting, so a shader permutation
+/*
+#ifndef RTXGI_DDGI_PROBE_SCROLL
+#define RTXGI_DDGI_PROBE_SCROLL 1
+#endif
+*/
+
+// ---------------------------------------------------
+
+#endif /* RTXGI_DDGI_VOLUME_DEFINES_H */
diff --git a/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/ddgi/Irradiance.ush b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/ddgi/Irradiance.ush
new file mode 100644
index 00000000000..03814601f5a
--- /dev/null
+++ b/Engine/Plugins/Runtime/Nvidia/RTXGI/Shaders/Private/SDK/ddgi/Irradiance.ush
@@ -0,0 +1,230 @@
+/*
+* Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef RTXGI_DDGI_IRRADIANCE_HLSL
+#define RTXGI_DDGI_IRRADIANCE_HLSL
+
+// These are turned on/off together in the plugin settings. Turned on if the lighting values are too large to be stored (like in extended radiance mode)
+#define RTXGI_DDGI_DEBUG_FORMAT_IRRADIANCE RTXGI_DDGI_DEBUG_FORMAT_RADIANCE
+
+#include "ProbeCommon.ush"
+
+struct DDGIVolumeResources
+{