diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1000_RaytracingQualityKeyword_PathTracer_Default.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1000_RaytracingQualityKeyword_PathTracer_Default.png index 3db1baabbd5..510a66bdae4 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1000_RaytracingQualityKeyword_PathTracer_Default.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/1000_RaytracingQualityKeyword_PathTracer_Default.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5bd13fedf367db42d061aabe39a07b8d5e557a87fef0be971e1460c784692d7 -size 594092 +oid sha256:08b57a5a118c31de7a0b88921a96aab1fe7f029eeed3e4bcd5e04d13067cb1a5 +size 594548 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/201_LargeAmbientOcclusion.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/201_LargeAmbientOcclusion.png index 1bdfaaec477..ea63eaa50a4 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/201_LargeAmbientOcclusion.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/201_LargeAmbientOcclusion.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb8fee11b0ada86c65e99dba270c1aa81bd35df939c9625a76a53e762ef366f0 -size 144623 +oid sha256:005b80510b9a3462ab0bfe7e03db36bb1f17b70dffd75f8a92efc18bde862cf1 +size 144719 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/202_LargeAmbientOcclusionDenoised.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/202_LargeAmbientOcclusionDenoised.png index d72bc39c3f3..45226939484 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/202_LargeAmbientOcclusionDenoised.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/202_LargeAmbientOcclusionDenoised.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d194f86e32e2ff59bc5133f0769983712b60686d67b92acc4ce87edcd6d2fe0e -size 400073 +oid sha256:b4380020c4b82672470fdc0d1eeaaf4cfde0756d91409bbf21f947194ea2c487 +size 400036 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/203_LocalAmbientOcclusionNoisy.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/203_LocalAmbientOcclusionNoisy.png index 289ebdb3412..cf05f36faa9 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/203_LocalAmbientOcclusionNoisy.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/203_LocalAmbientOcclusionNoisy.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7dd05d2ea697861ac8dc2fd49c35a5e9cc294d83474bdfa2ce78bdea54851827 -size 206914 +oid sha256:67a7152f306af4a22ce50281d593efa8b6cbd726266f3ade39c1afd1f0124b02 +size 208153 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/204_LocalAmbientOcclusionDenoised.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/204_LocalAmbientOcclusionDenoised.png index ca95392224e..a71162e101a 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/204_LocalAmbientOcclusionDenoised.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/204_LocalAmbientOcclusionDenoised.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb3ee4209d2280e044ce4491ea54a8c3f5cd3532d94806e38617e077a160c597 -size 424915 +oid sha256:befef94c5b5411a3aa4f7da787f2aa3f7382aea45f2084b1b52a68be245aaec1 +size 424552 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsDeferred.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsDeferred.png index 131933e7cc9..bb2845cea23 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsDeferred.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsDeferred.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4da9432871cff1ff6d92d06d67f49a19bda814e2e022d03745823426968bf4d5 -size 337460 +oid sha256:9ac30ae9e08fce97ca1f4c37617a41eaa2c7bef065cf6ddb0cc0fd34052672fa +size 307716 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsForward.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsForward.png index 1fd1b5b13ed..68cbd4efaec 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsForward.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/3001_AreaShadowsForward.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77776f4f55f0e7197d09c55da2216083b287f450934148af0aba71c1a5e50f67 -size 320508 +oid sha256:713377f7ff07d60ac32f829d400e3868b5e32bc4d3c2ac79b99f173db11b706f +size 289480 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFull.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFull.png index f927ab6ba75..ab6d72c0dae 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFull.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFull.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5846572053f940582ebc5adda12e7d7410795e71373201c95b1378341392dac8 -size 598630 +oid sha256:c655691ed383fb158ab471098f0aad6cc7385a3ba7d3692f3914edace75dca50 +size 598547 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFullLightLayers.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFullLightLayers.png index 1a252036f66..ab6d72c0dae 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFullLightLayers.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/301_GlobalIlluminationPerfFullLightLayers.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6507e48fadc4fdb35f84b137b4674a9b96f151066c4ddcd42f6c16759b38808d -size 667745 +oid sha256:c655691ed383fb158ab471098f0aad6cc7385a3ba7d3692f3914edace75dca50 +size 598547 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/302_GlobalIlluminationPerfHalf.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/302_GlobalIlluminationPerfHalf.png index c41c7c2e831..0dbb0395035 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/302_GlobalIlluminationPerfHalf.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/302_GlobalIlluminationPerfHalf.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b936997e46e2e41449a619fbffc5a9aee214b92945e9bf9fc078d90ab6a0c9f -size 624479 +oid sha256:9cb1fb2427e4854c0c30351482e3c99ff0edada20b3a2a6c01ada2607e1ac46b +size 624661 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/303_GlobalIlluminationQuality.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/303_GlobalIlluminationQuality.png index 31f29eea6a7..78b2ac8e756 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/303_GlobalIlluminationQuality.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/303_GlobalIlluminationQuality.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ddbd4ab23be231ede3c8cf2566700d55b0a719204cb2491f7414e8691bdf5d5 -size 677232 +oid sha256:09b6e43ad80f7beff782b6e67981de705b0c14ef35cb5fe7258a17e17d89e29d +size 677024 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/304_GlobalIlluminationDenoised1.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/304_GlobalIlluminationDenoised1.png index f849c1f1d7f..84e8ed383cb 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/304_GlobalIlluminationDenoised1.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/304_GlobalIlluminationDenoised1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d262e35ccb13b1105b1ae00ab6d5fd2a2ca1fa1ef86fe4a79dbed548ed5d112f -size 565063 +oid sha256:922f6befa2d70e8afb61ac7f10dc035055f13853ea47eca47da8df64283d0432 +size 564560 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/305_GlobalIlluminationDenoisedHalf1.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/305_GlobalIlluminationDenoisedHalf1.png index 8c10957aeb1..979c4de3300 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/305_GlobalIlluminationDenoisedHalf1.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/305_GlobalIlluminationDenoisedHalf1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8e0d78e4c4befff7685ef00bea4630cd3486881216079b8a4779bd5dbe842808 -size 289541 +oid sha256:5983b6337c4900f9b94676562b372d4aa3d14b1363d07f87d10b877b802ccad8 +size 289175 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/306_GlobalIlluminationDenoised2.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/306_GlobalIlluminationDenoised2.png index f5564677c4d..44b0e2cfee6 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/306_GlobalIlluminationDenoised2.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/306_GlobalIlluminationDenoised2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:204f3f31529fcf62cdeeb6ad951864bce13a58014f504712e02917d46b71e332 -size 460144 +oid sha256:6f94089dc0b62d35bf073dcc8f7f71dbc4a2a8e3d1b512fadfe7e255c4072f2e +size 459411 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/307_GlobalIlluminationFog.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/307_GlobalIlluminationFog.png index 0eb4b6b2e07..5eff2c6b3a8 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/307_GlobalIlluminationFog.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/307_GlobalIlluminationFog.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:05cdaa37a837309e0fb7746e928c8ea619340a3e36e085533eadc3126df3186e -size 431316 +oid sha256:06166c87865fbc833efbc4498f658a44d331b9de2a5d4249613824c9eb9954ba +size 430880 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5001_PathTracing.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5001_PathTracing.png index 42836bef2d4..0bfaf7bc659 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5001_PathTracing.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5001_PathTracing.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c41d3240cc1a61873e44b11f3727b02b0796b9a15a21ad28e1b072c3cf53ba30 -size 594955 +oid sha256:0b3ee66248fbe0d0efd11cc27f449512991d36bbdcd4cf67f81bbccca3be19e9 +size 595123 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5002_PathTracing_GI.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5002_PathTracing_GI.png index adf0c6cee30..ee899eccdb8 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5002_PathTracing_GI.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5002_PathTracing_GI.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63c58974f312e0e16055ba4dc98a89c98b5a5f63806947f884b59d5e1d9c5047 -size 145858 +oid sha256:fee73f0f3bf5fc030aa4cc5eead6f4a851ff5aa10d77a46a5141f7508836d361 +size 146056 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5003_PathTracing_transparency.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5003_PathTracing_transparency.png index d373862e147..dd69b1a423e 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5003_PathTracing_transparency.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5003_PathTracing_transparency.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94b15e3f04fea302b44fc24973c3271fb93cc193ebf512e5c66783eccf5af478 -size 816378 +oid sha256:dc38ea9ae91b8ee15318c1e62948c30de267fa3f18ee31988c31db3c543ea21b +size 816829 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5004_PathTracing_arealight.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5004_PathTracing_arealight.png index f1ba4805c13..852f39a720f 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5004_PathTracing_arealight.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5004_PathTracing_arealight.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4a812bb84d35db5575a730bf753959063c30fb21921a003cb988e2aa4cd711e2 -size 171136 +oid sha256:dc1a2173a5e35298161b2811511f154e81dfbab75fcc30d40a044b0f4f099477 +size 171551 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5005_PathTracing_Fog.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5005_PathTracing_Fog.png index 3acc0724825..7280ba1fb75 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5005_PathTracing_Fog.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5005_PathTracing_Fog.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81d3b4dad30801833f6b3cff97726c9084e95b5bcfa2ece8e1fe347525901609 -size 333921 +oid sha256:c395ab1c4b6490a09e59522d463fd2a64f4ada3a5de95d9a1b1f15f6085fb2fe +size 333531 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5006_PathTracing_DoF.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5006_PathTracing_DoF.png index 9ce3911c7b6..9f615549e99 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5006_PathTracing_DoF.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5006_PathTracing_DoF.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:293a4b4420f4ff33b083bae34a3b9bff853b3b29e5d06a9308aa365781280882 -size 582743 +oid sha256:f0d0ee8840624839d44e46b03d4fb624dee9a7f889b78a064f21f788bb734d01 +size 582422 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png index 3c2b86b7071..39f79b0fa2f 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Lit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:808bf35a152913a2050829abb22df34d4796b0ee997ec0f4f5fd5633a5eb7675 -size 512130 +oid sha256:725c3b80a3d7276968bffc9deebe56c019716790f524c0473b66d68a339e6915 +size 425111 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Unlit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Unlit.png index ed7cff3fef2..5a5c85e20aa 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Unlit.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5007_PathTracing_Materials_SG_Unlit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75313116e965773d446e8027dc8e7ff244114bfef9cdc226fd7da260394de554 -size 55192 +oid sha256:7a3e844edd86e44eac4f82b651d4aed5bcd51a8a5037ff43c2da12d61e4b386c +size 54995 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5008_PathTracing_NormalMapping.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5008_PathTracing_NormalMapping.png index f316c3dcf34..79b3d5676c3 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5008_PathTracing_NormalMapping.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/5008_PathTracing_NormalMapping.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:689f1b1db73d6d3a717d4d615403f7977e64bdf1f505e26bbb7afda54ae11d81 -size 788532 +oid sha256:988900879c0dc8e9bb026ede6039131020e69f9e13e3eb5def73d058d596717e +size 690107 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png index 427767bab4d..37ba482a590 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/801_SubSurfaceScatteringDeferred.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63310a095e4923e58f4a1171f4ed154acbdce084bc16dd9367935d4270fc74df -size 176871 +oid sha256:217eba3acb0edfb22bdb2d8c6577df54b6b27393a40b6e462092463d69bd1d10 +size 176647 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png index 5014a27c9a4..3f9a67bc066 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/802_SubSurfaceScatteringForward.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:797184bbcb6e8a3d006fff007ef081c940e078df17063ab9729d18b9df009b72 -size 176965 +oid sha256:9f9a6c32e075ae9dacc5963f642d638841e4b97763106bb2bb2b001b34de2087 +size 176239 diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 2d9422a84f7..eb3b3d23e3f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -21,6 +21,7 @@ The version number for this package has increased due to a version update of a r - Added frame setting for Virtual Texturing. - Added a fade distance for light influencing volumetric lighting. - Adding an "Include For Ray Tracing" toggle on lights to allow the user to exclude them when ray tracing is enabled in the frame settings of a camera. +- Added fog volumetric scattering support for path tracing. ### Fixed - Fixed an issue where the Exposure Shader Graph node had clipped text. (case 1265057) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs index 4c57c1b55b7..187c2a710f8 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs @@ -46,6 +46,7 @@ public HDLitData litData protected override string postDecalsInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Lit; protected override string raytracingInclude => CoreIncludes.kLitRaytracing; + protected override string pathtracingInclude => CoreIncludes.kLitPathtracing; protected override FieldDescriptor subShaderField => new FieldDescriptor(kSubShader, "Lit Subshader", ""); protected override string subShaderInclude => CoreIncludes.kLit; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs index aaf1322765f..82dd14c24c5 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs @@ -1115,8 +1115,8 @@ IncludeCollection GenerateIncludes() // Each material has a specific hlsl file that should be included pre-graph and holds the lighting model includes.Add(CoreIncludes.kPassPlaceholder, IncludeLocation.Pregraph); - // We need to then include the ray tracing missing bits for the lighting models (based on which lighting model) - includes.Add(CoreIncludes.kRaytracingPlaceholder, IncludeLocation.Pregraph); + // We need to then include path tracing support for the material + includes.Add(CoreIncludes.kPathtracingPlaceholder, IncludeLocation.Pregraph); includes.Add(CoreIncludes.CoreUtility); includes.Add(CoreIncludes.kRaytracingCommon, IncludeLocation.Pregraph); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs index a3955bc346c..523ec270bb8 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs @@ -50,6 +50,7 @@ public SystemData systemData protected virtual string postDecalsInclude => null; protected virtual string raytracingInclude => null; + protected virtual string pathtracingInclude => null; protected virtual bool supportPathtracing => false; protected virtual bool supportRaytracing => false; @@ -148,6 +149,8 @@ protected SubShaderDescriptor PostProcessSubShader(SubShaderDescriptor subShader include.descriptor.value = postDecalsInclude; if (include.descriptor.value == CoreIncludes.kRaytracingPlaceholder) include.descriptor.value = raytracingInclude; + if (include.descriptor.value == CoreIncludes.kPathtracingPlaceholder) + include.descriptor.value = pathtracingInclude; if (!String.IsNullOrEmpty(include.descriptor.value)) finalIncludes.Add(include.descriptor.value, include.descriptor.location, include.fieldConditions); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs index befd7bb5f07..c8681682202 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs @@ -873,6 +873,7 @@ static class CoreIncludes public const string kRaytracingIntersectionGBuffer = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingIntersectonGBuffer.hlsl"; public const string kRaytracingIntersectionSubSurface = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/SubSurface/RayTracingIntersectionSubSurface.hlsl"; public const string kLitRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl"; + public const string kLitPathtracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl"; public const string kUnlitRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitRaytracing.hlsl"; public const string kFabricRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/FabricRaytracing.hlsl"; public const string kEyeRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/EyeRaytracing.hlsl"; @@ -913,6 +914,7 @@ static class CoreIncludes public const string kPassPlaceholder = "Pass Include Placeholder, replace me !"; public const string kPostDecalsPlaceholder = "After Decal Include Placeholder, replace me !"; public const string kRaytracingPlaceholder = "Raytracing Include Placeholder, replace me !"; + public const string kPathtracingPlaceholder = "Pathtracing Include Placeholder, replace me !"; // Public Postgraph Pass public const string kPassLightTransport = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl"; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl index 493a656b1a3..d261c7b1e44 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -1,3 +1,6 @@ +#ifndef UNITY_LIGHT_EVALUATION_INCLUDED +#define UNITY_LIGHT_EVALUATION_INCLUDED + // This files include various function uses to evaluate lights // use #define LIGHT_EVALUATION_NO_HEIGHT_FOG to disable Height fog attenuation evaluation // use #define LIGHT_EVALUATION_NO_COOKIE to disable cookie evaluation @@ -582,3 +585,5 @@ void ApplyScreenSpaceReflectionWeight(inout float4 ssrLighting) ssrLighting.rgb *= ssrLighting.a; } #endif + +#endif // UNITY_LIGHT_EVALUATION_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl index 0a0d951d650..3a511f7ba16 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl @@ -1,3 +1,6 @@ +#ifndef UNITY_COOKIE_SAMPLING_INCLUDED +#define UNITY_COOKIE_SAMPLING_INCLUDED + //----------------------------------------------------------------------------- // Cookie sampling functions // ---------------------------------------------------------------------------- @@ -47,3 +50,5 @@ float3 SamplePointCookie(float3 lightToSample, float4 scaleOffset, float lod = 0 return SampleCookie2D(uv, scaleOffset, lod); } + +#endif // UNITY_COOKIE_SAMPLING_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl index dfafa624f85..4fb26d5b60d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl @@ -1,3 +1,6 @@ +#ifndef UNITY_LIGHT_LOOP_DEF_INCLUDED +#define UNITY_LIGHT_LOOP_DEF_INCLUDED + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl" @@ -375,3 +378,5 @@ float3 GetScreenSpaceColorShadow(PositionInputs posInput, int shadowIndex) float4 res = LOAD_TEXTURE2D_ARRAY(_ScreenSpaceShadowsTexture, posInput.positionSS, INDEX_TEXTURE2D_ARRAY_X(shadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK)); return (SCREEN_SPACE_COLOR_SHADOW_FLAG & shadowIndex) ? res.xyz : res.xxx; } + +#endif // UNITY_LIGHT_LOOP_DEF_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader index cbd563f03ca..52c29075102 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader @@ -1137,7 +1137,6 @@ Shader "HDRP/LayeredLit" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracingLightLoop.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" @@ -1145,11 +1144,10 @@ Shader "HDRP/LayeredLit" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" #define HAS_LIGHTLOOP + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl" ENDHLSL diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader index 274e2ddcbf3..a502d716f12 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader @@ -1153,14 +1153,13 @@ Shader "HDRP/Lit" #define SHADERPASS SHADERPASS_PATH_TRACING - // This is just because it need to be defined, shadow maps are not used. + // This is just because it needs to be defined, shadow maps are not used. #define SHADOW_LOW #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracingLightLoop.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" @@ -1168,11 +1167,10 @@ Shader "HDRP/Lit" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" #define HAS_LIGHTLOOP - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl" ENDHLSL diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader index ae2ccd570f2..9874e7593f2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader @@ -606,6 +606,9 @@ Shader "HDRP/Unlit" #define SHADERPASS SHADERPASS_PATH_TRACING + #define SHADER_UNLIT + #define HAS_LIGHTLOOP // Used when computing volumetric scattering + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" @@ -616,7 +619,6 @@ Shader "HDRP/Unlit" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs index 640f179af0b..5bfd3ce6183 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/SubFrameManager.cs @@ -311,7 +311,7 @@ RenderAccumulationParameters PrepareRenderAccumulationParameters(HDCamera hdCame void RenderAccumulation(HDCamera hdCamera, RTHandle inputTexture, RTHandle outputTexture, bool needExposure, CommandBuffer cmd) { - // Grab the history buffer (hijack the reflections one) + // Grab the history buffer RTHandle history = hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing) ?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 12457c68813..f629975ef20 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -1406,7 +1406,7 @@ void RenderAccumulation(RenderGraph renderGraph, HDCamera hdCamera, TextureHandl { using (var builder = renderGraph.AddRenderPass("Render Accumulation", out var passData)) { - // Grab the history buffer (hijack the reflections one) + // Grab the history buffer TextureHandle history = renderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing) ?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1)); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl index a56b52c75bb..a19184de880 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl @@ -1,6 +1,7 @@ #ifndef UNITY_PATH_TRACING_BSDF_INCLUDED #define UNITY_PATH_TRACING_BSDF_INCLUDED +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/SubSurface.hlsl" #define DELTA_PDF 1000000.0 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl index 2d03176e5d8..419793ad3cd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl @@ -1,6 +1,18 @@ #ifndef UNITY_PATH_TRACING_LIGHT_INCLUDED #define UNITY_PATH_TRACING_LIGHT_INCLUDED +// This is just because it need to be defined, shadow maps are not used. +#define SHADOW_LOW + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl" + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracingLightLoop.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RayTracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl" + // How many lights (at most) do we support at one given shading point // FIXME: hardcoded limits are evil, this LightList should instead be put together in C# #define MAX_LOCAL_LIGHT_COUNT 16 @@ -27,21 +39,21 @@ struct LightList bool IsRectAreaLightActive(LightData lightData, float3 position, float3 normal) { - float3 lightVec = position - lightData.positionRWS; + float3 lightToPosition = position - lightData.positionRWS; #ifndef USE_LIGHT_CLUSTER // Check light range first - if (Length2(lightVec) > Sq(lightData.range)) + if (Length2(lightToPosition) > Sq(lightData.range)) return false; #endif // Check that the shading position is in front of the light - float lightCos = dot(lightVec, lightData.forward); + float lightCos = dot(lightToPosition, lightData.forward); if (lightCos < 0.0) return false; // Check that at least part of the light is above the tangent plane - float lightTangentDist = dot(normal, lightVec); + float lightTangentDist = dot(normal, lightToPosition); if (4.0 * lightTangentDist * abs(lightTangentDist) > Sq(lightData.size.x) + Sq(lightData.size.y)) return false; @@ -50,16 +62,16 @@ bool IsRectAreaLightActive(LightData lightData, float3 position, float3 normal) bool IsPointLightActive(LightData lightData, float3 position, float3 normal) { - float3 lightVec = position - lightData.positionRWS; + float3 lightToPosition = position - lightData.positionRWS; #ifndef USE_LIGHT_CLUSTER // Check light range first - if (Length2(lightVec) > Sq(lightData.range)) + if (Length2(lightToPosition) > Sq(lightData.range)) return false; #endif // Check that at least part of the light is above the tangent plane - float lightTangentDist = dot(normal, lightVec); + float lightTangentDist = dot(normal, lightToPosition); if (lightTangentDist * abs(lightTangentDist) > lightData.size.x) return false; @@ -68,7 +80,7 @@ bool IsPointLightActive(LightData lightData, float3 position, float3 normal) return true; // Check that we are on the right side of the light plane - float z = dot(lightVec, lightData.forward); + float z = dot(lightToPosition, lightData.forward); if (z < 0.0) return false; @@ -78,31 +90,37 @@ bool IsPointLightActive(LightData lightData, float3 position, float3 normal) // then check whether we are still within the dilated cone angle float sinTheta2 = 1.0 - Sq(lightData.angleOffset / lightData.angleScale); float3 lightRadiusOffset = sqrt(lightData.size.x / sinTheta2) * lightData.forward; - float lightCos = dot(normalize(lightVec + lightRadiusOffset), lightData.forward); + float lightCos = dot(normalize(lightToPosition + lightRadiusOffset), lightData.forward); return lightCos * lightData.angleScale + lightData.angleOffset > 0.0; } // Our light type is either BOX or PYRAMID - float x = abs(dot(lightVec, lightData.right)); - float y = abs(dot(lightVec, lightData.up)); + float x = abs(dot(lightToPosition, lightData.right)); + float y = abs(dot(lightToPosition, lightData.up)); return (lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) ? - x < 1 && y < 1 : // BOX - x < z && y < z; // PYRAMID + x < 1.0 && y < 1.0 : // BOX + x < z && y < z; // PYRAMID } bool IsDistantLightActive(DirectionalLightData lightData, float3 normal) { - return dot(normal, lightData.forward) < sin(lightData.angularDiameter * 0.5); + return dot(normal, lightData.forward) <= sin(lightData.angularDiameter * 0.5); } -LightList CreateLightList(float3 position, float3 normal, uint lightLayers) +LightList CreateLightList(float3 position, float3 normal, uint lightLayers, bool withLocal = true, bool withDistant = true) { LightList list; + uint i; // First take care of local lights (point, area) - uint i, localPointCount, localCount; + list.localCount = 0; + list.localPointCount = 0; + +if (withLocal) +{ + uint localPointCount, localCount; #ifdef USE_LIGHT_CLUSTER if (PointInsideCluster(position)) @@ -122,7 +140,7 @@ LightList CreateLightList(float3 position, float3 normal, uint lightLayers) #endif // First point lights (including spot lights) - for (list.localPointCount = 0, i = 0; i < localPointCount && list.localPointCount < MAX_LOCAL_LIGHT_COUNT; i++) + for (i = 0; i < localPointCount && list.localPointCount < MAX_LOCAL_LIGHT_COUNT; i++) { #ifdef USE_LIGHT_CLUSTER const LightData lightData = FetchClusterLightIndex(list.cellIndex, i); @@ -130,11 +148,7 @@ LightList CreateLightList(float3 position, float3 normal, uint lightLayers) const LightData lightData = _LightDatasRT[i]; #endif - if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) -#ifndef _SURFACE_TYPE_TRANSPARENT - && IsPointLightActive(lightData, position, normal) -#endif - ) + if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsPointLightActive(lightData, position, normal)) list.localIndex[list.localPointCount++] = i; } @@ -147,26 +161,22 @@ LightList CreateLightList(float3 position, float3 normal, uint lightLayers) const LightData lightData = _LightDatasRT[i]; #endif - if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) -#ifndef _SURFACE_TYPE_TRANSPARENT - && IsRectAreaLightActive(lightData, position, normal) -#endif - ) + if (IsMatchingLightLayer(lightData.lightLayers, lightLayers) && IsRectAreaLightActive(lightData, position, normal)) list.localIndex[list.localCount++] = i; } +} // Then filter the active distant lights (directional) list.distantCount = 0; +if (withDistant) +{ for (i = 0; i < _DirectionalLightCount && list.distantCount < MAX_DISTANT_LIGHT_COUNT; i++) { - if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, lightLayers) -#ifndef _SURFACE_TYPE_TRANSPARENT - && IsDistantLightActive(_DirectionalLightDatas[i], normal) -#endif - ) + if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, lightLayers) && IsDistantLightActive(_DirectionalLightDatas[i], normal)) list.distantIndex[list.distantCount++] = i; } +} // Compute the weights, used for the lights PDF (we split 50/50 between local and distant, if both are present) list.localWeight = list.localCount ? (list.distantCount ? 0.5 : 1.0) : 0.0; @@ -298,6 +308,9 @@ bool SampleLights(LightList lightList, if (!GetLightCount(lightList)) return false; + // Are we lighting a volume or a surface? + bool isVolume = !any(normal); + if (PickLocalLights(lightList, inputSample.z)) { // Pick a local light from the list @@ -317,7 +330,7 @@ bool SampleLights(LightList lightList, dist = sqrt(sqDist); outgoingDir /= dist; - if (dot(normal, outgoingDir) < 0.001) + if (!isVolume && dot(normal, outgoingDir) < 0.001) return false; float cosTheta = -dot(outgoingDir, lightData.forward); @@ -351,13 +364,16 @@ bool SampleLights(LightList lightList, pdf = DELTA_PDF; } - if (dot(normal, outgoingDir) < 0.001) + if (!isVolume && dot(normal, outgoingDir) < 0.001) return false; value = GetPunctualEmission(lightData, outgoingDir, dist) * pdf; pdf = GetLocalLightWeight(lightList) * pdf; } + if (isVolume) + value *= lightData.volumetricLightDimmer; + #ifndef LIGHT_EVALUATION_NO_HEIGHT_FOG ApplyFogAttenuation(position, outgoingDir, dist, value); #endif @@ -384,11 +400,14 @@ bool SampleLights(LightList lightList, outgoingDir = -lightData.forward; } - if (dot(normal, outgoingDir) < 0.001) + if (!isVolume && (dot(normal, outgoingDir) < 0.001)) return false; dist = FLT_INF; + if (isVolume) + value *= lightData.volumetricLightDimmer; + #ifndef LIGHT_EVALUATION_NO_HEIGHT_FOG ApplyFogAttenuation(position, outgoingDir, value); #endif @@ -468,4 +487,225 @@ void EvaluateLights(LightList lightList, } } +// Functions used by volumetric sampling + +bool SolvePoly2(float a, float b, float c, out float x1, out float x2) +{ + float det = Sq(b) - 4.0 * a * c; + + if (det < 0.0) + return false; + + float sqrtDet = sqrt(det); + x1 = (-b - sign(a) * sqrtDet) / (2.0 * a); + x2 = (-b + sign(a) * sqrtDet) / (2.0 * a); + + return true; +} + +bool GetSphereInterval(float3 lightToRayOrigin, float radius, float3 rayDirection, out float tMin, out float tMax) +{ + // We consider Direction to be normalized => a = 1 + float b = 2.0 * dot(rayDirection, lightToRayOrigin); + float c = Length2(lightToRayOrigin) - Sq(radius); + + float t1, t2; + if (!SolvePoly2(1.0, b, c, t1, t2)) + return false; + + tMin = max(t1, 0.0); + tMax = max(t2, 0.0); + + return tMin < tMax; +} + +bool GetRectAreaLightInterval(LightData lightData, float3 rayOrigin, float3 rayDirection, out float tMin, out float tMax) +{ + if (lightData.volumetricLightDimmer < 0.001) + return false; + + float3 lightToRayOrigin = rayOrigin - lightData.positionRWS; + + if (!GetSphereInterval(lightToRayOrigin, lightData.range, rayDirection, tMin, tMax)) + return false; + + float LdotD = dot(lightData.forward, rayDirection); + float t = -dot(lightData.forward, lightToRayOrigin) / LdotD; + if (LdotD > 0.0) + tMin = max(tMin, t); + else + tMax = min(tMax, t); + + return tMin < tMax; +} + +void Sort(inout float x, inout float y) +{ + if (x > y) + { + float tmp = x; + x = y; + y = tmp; + } +} + +void GetFrontInterval(float oz, float dz, float t1, float t2, inout float tMin, inout float tMax) +{ + bool t1Valid = oz + t1 * dz > 0.0; + bool t2Valid = oz + t2 * dz > 0.0; + + if (t1Valid) + { + if (t2Valid) + { + tMin = max(t1, tMin); + tMax = min(t2, tMax); + } + else + { + tMax = min(t1, tMax); + } + } + else + { + tMin = t2Valid ? max(t2, tMin) : tMax; + } +} + +bool GetPointLightInterval(LightData lightData, float3 rayOrigin, float3 rayDirection, out float tMin, out float tMax) +{ + if (lightData.volumetricLightDimmer < 0.001) + return false; + + float3 lightToRayOrigin = rayOrigin - lightData.positionRWS; + + if (!GetSphereInterval(lightToRayOrigin, lightData.range, rayDirection, tMin, tMax)) + return false; + + // This is just a point light (no spot cone angle) + if (lightData.lightType == GPULIGHTTYPE_POINT) + return true; + + // We are dealing with either a cone, a pyramid or a box + float3 localOrigin = float3(dot(lightToRayOrigin, lightData.right), + dot(lightToRayOrigin, lightData.up), + dot(lightToRayOrigin, lightData.forward)); + float3 localDirection = float3(dot(rayDirection, lightData.right), + dot(rayDirection, lightData.up), + dot(rayDirection, lightData.forward)); + + if (lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) + { + // Compute intersections with planes x=-1 and x=1 + float tx1 = (-1.0 - localOrigin.x) / localDirection.x; + float tx2 = (1.0 - localOrigin.x) / localDirection.x; + Sort(tx1, tx2); + + // Compute intersections with planes y=-1 and y=1 + float ty1 = (-1.0 - localOrigin.y) / localDirection.y; + float ty2 = (1.0 - localOrigin.y) / localDirection.y; + Sort(ty1, ty2); + + // Compute intersection with plane z=0 + float tz = -localOrigin.z / localDirection.z; + + float t1 = max(tx1, ty1); + float t2 = min(tx2, ty2); + + // Check validity of the intersections (we want them only in front of the light) + bool t1Valid = localOrigin.z + t1 * localDirection.z > 0.0; + bool t2Valid = localOrigin.z + t2 * localDirection.z > 0.0; + + tMin = t1Valid ? max(t1, tMin) : tz; + tMax = t2Valid ? min(t2, tMax) : tz; + } + else if (lightData.lightType == GPULIGHTTYPE_PROJECTOR_PYRAMID) + { + // Compute intersections with planes x=-z and x=z + float tx1 = -(localOrigin.x - localOrigin.z) / (localDirection.x - localDirection.z); + float tx2 = -(localOrigin.x + localOrigin.z) / (localDirection.x + localDirection.z); + Sort(tx1, tx2); + + // Check validity of the intersections (we want them only in front of the light) + GetFrontInterval(localOrigin.z, localDirection.z, tx1, tx2, tMin, tMax); + + if (tMin < tMax) + { + // Compute intersections with planes y=-1 and y=1 + float ty1 = -(localOrigin.y - localOrigin.z) / (localDirection.y - localDirection.z); + float ty2 = -(localOrigin.y + localOrigin.z) / (localDirection.y + localDirection.z); + Sort(ty1, ty2); + + // Check validity of the intersections (we want them only in front of the light) + GetFrontInterval(localOrigin.z, localDirection.z, ty1, ty2, tMin, tMax); + } + } + else // lightData.lightType == GPULIGHTTYPE_SPOT + { + float cosTheta2 = Sq(lightData.angleOffset / lightData.angleScale); + + // Offset light origin to account for light radius + localOrigin.z += sqrt(lightData.size.x / (1.0 - cosTheta2)); + + // Account for non-normalized local basis + float3 normalizedLocalOrigin = float3(localOrigin.x / Length2(lightData.right), + localOrigin.y / Length2(lightData.up), + localOrigin.z); + + float a = Sq(localDirection.z) - cosTheta2; + float b = 2.0 * (localOrigin.z * localDirection.z - dot(normalizedLocalOrigin, localDirection) * cosTheta2); + float c = Sq(localOrigin.z) - dot(normalizedLocalOrigin, localOrigin) * cosTheta2; + + float t1, t2; + if (!SolvePoly2(a, b, c, t1, t2)) + return false; + + // Check validity of the intersections (we want them only in front of the light) + GetFrontInterval(localOrigin.z, localDirection.z, t1, t2, tMin, tMax); + } + + return tMin < tMax; +} + +float GetLocalLightsInterval(float3 rayOrigin, float3 rayDirection, out float tMin, out float tMax) +{ + tMin = FLT_MAX; + tMax = 0.0; + + float tLightMin, tLightMax; + + // First process point lights + uint i = 0, n = _PunctualLightCountRT, localCount = 0; + for (; i < n; i++) + { + if (GetPointLightInterval(_LightDatasRT[i], rayOrigin, rayDirection, tLightMin, tLightMax)) + { + tMin = min(tMin, tLightMin); + tMax = max(tMax, tLightMax); + localCount++; + } + } + + // Then area lights + n += _AreaLightCountRT; + for (; i < n; i++) + { + if (GetRectAreaLightInterval(_LightDatasRT[i], rayOrigin, rayDirection, tLightMin, tLightMax)) + { + tMin = min(tMin, tLightMin); + tMax = max(tMax, tLightMax); + localCount++; + } + } + + uint lightCount = localCount + _DirectionalLightCount; + + return lightCount ? float(localCount) / lightCount : -1.0; +} + +LightList CreateLightList(float3 position, bool sampleLocalLights) +{ + return CreateLightList(position, 0.0, ~0, sampleLocalLights, !sampleLocalLights); +} + #endif // UNITY_PATH_TRACING_LIGHT_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace index 7aa163d0b59..04b8b7e47dc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace @@ -12,11 +12,15 @@ // Ray tracing includes #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RayTracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl" + +// We need this for the potential volumetric integration on camera misses +#define HAS_LIGHTLOOP // Path tracing includes #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingIntersection.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RayTracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl" // Input(s) float4x4 _PixelCoordToViewDirWS; @@ -24,7 +28,7 @@ int _RaytracingCameraSkyEnabled; float3 _RaytracingCameraClearColor; // DoF related parameters -float4 _PathTracedDoFConstants; // x: aperture radius, y: focus distance, zw: unused +float4 _PathTracedDoFConstants; // x: aperture radius, y: focus distance, zw: unused // Output(s) RWTexture2D _RadianceTexture; @@ -37,6 +41,33 @@ void MissCamera(inout PathIntersection pathIntersection : SV_RayPayload) SampleSkyTexture(WorldRayDirection(), 0.0, 0).xyz : _RaytracingCameraClearColor * GetInverseCurrentExposureMultiplier(); ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value); + + if (_EnableVolumetricFog && _RaytracingMinRecursion <= 1) + { + float3 envValue = pathIntersection.value; + + // Generate a 4D unit-square sample for this depth, from our QMC sequence + float4 inputSample = GetSample4D(pathIntersection.pixelCoord, _RaytracingSampleIndex, 0); + + // Compute volumetric scattering + pathIntersection.value = 0.0; + pathIntersection.t = FLT_MAX; + float pdf = 1.0; + bool sampleLocalLights; + if (SampleVolumeScatteringPosition(inputSample.w, pathIntersection.t, pdf, sampleLocalLights)) + { + ComputeVolumeScattering(pathIntersection, inputSample.xyz, sampleLocalLights); + + // Apply the pdf + pathIntersection.value /= pdf; + + // Apply volumetric attenuation + ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.t, pathIntersection.value); + } + + // Reinject the environment value + pathIntersection.value += envValue; + } } [shader("miss")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl index f0b1c0f4e1c..b7bf648cb5a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl @@ -11,6 +11,20 @@ float GetSample(uint2 coord, uint index, uint dim) return GetBNDSequenceSample(coord, index, dim); } +float4 GetSample4D(uint2 coord, uint index, uint dim) +{ + // If we go past the number of stored samples per dim, just shift all to the next pair of dimensions + dim += (index / 256) * 2; + + float4 sample; + sample.x = GetBNDSequenceSample(coord, index, dim); + sample.y = GetBNDSequenceSample(coord, index, dim + 1); + sample.z = GetBNDSequenceSample(coord, index, dim + 2); + sample.w = GetBNDSequenceSample(coord, index, dim + 3); + + return sample; +} + bool RussianRouletteTest(float threshold, float value, float rand, out float factor, bool skip = false) { if (skip || value >= threshold) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl new file mode 100644 index 00000000000..9a6cf4279a2 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl @@ -0,0 +1,179 @@ +#ifndef UNITY_PATH_TRACING_VOLUME_INCLUDED +#define UNITY_PATH_TRACING_VOLUME_INCLUDED + +#ifdef HAS_LIGHTLOOP +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl" +#endif + +float ComputeHeightFogMultiplier(float height) +{ + return ComputeHeightFogMultiplier(height, _HeightFogBaseHeight, _HeightFogExponents); +} + +bool SampleVolumeScatteringPosition(inout float sample, inout float t, inout float pdf, out bool sampleLocalLights) +{ + sampleLocalLights = false; + + if (!_FogEnabled || !_EnableVolumetricFog) + return false; + + // This will determin the interval in which volumetric scattering can occur + float tMin, tMax; + float pdfVol = 1.0; + float tFog = min(t, _MaxFogDistance); + +#ifdef HAS_LIGHTLOOP + float localWeight = GetLocalLightsInterval(WorldRayOrigin(), WorldRayDirection(), tMin, tMax); + + if (localWeight < 0.0) + return false; + + sampleLocalLights = sample < localWeight; + if (sampleLocalLights) + { + tMax = min(tMax, tFog); + if (tMin >= tMax) + return false; + + sample /= localWeight; + pdfVol *= localWeight; + } + else + { + tMin = 0.0; + tMax = tFog; + + sample -= localWeight; + sample /= 1.0 - localWeight; + pdfVol *= 1.0 - localWeight; + } +#else + tMin = 0.0; + tMax = tFog; +#endif + + // FIXME: not quite sure what the sigmaS, sigmaT values are supposed to be... + const float sigmaS = (t == FLT_MAX) ? 1.0 : sqrt(Luminance(_HeightFogBaseScattering.xyz)); + const float sigmaT = _HeightFogBaseExtinction; + const float transmittanceMax = exp(-tMax * sigmaT); + + const float pdfNoVolA = 1.0 - sigmaS; + const float pdfNoVolB = sigmaS * transmittanceMax; + const float pdfNoVol = pdfNoVolA + pdfNoVolB; + pdfVol *= 1.0 - pdfNoVol; + + if (sample >= sigmaS) + { + // Re-scale the sample + sample -= sigmaS; + sample /= 1.0 - sigmaS; + + // Set the pdf + pdf *= pdfNoVol; + + return false; + } + + // Re-scale the sample + sample /= sigmaS; + + // Evaluate the length to a potential volume scattering event + if (-log(1.0 - sample) / sigmaT >= tMax) + { + // Re-scale the sample + sample -= 1.0 - transmittanceMax; + sample /= transmittanceMax; + + // Set the pdf + pdf *= pdfNoVol; + + return false; + } + + if (sampleLocalLights) + { + // Re-scale the sample + sample /= 1.0 - transmittanceMax; + + // Linear sampling + float deltaT = tMax - tMin; + t = tMin + sample * deltaT; + + // Set the pdf + pdf *= pdfVol / deltaT; + } + else + { + // Let's (avoid very low transmittance, for robustness sake (minor bias) + if (transmittanceMax < 0.01) + sample = sample * 0.99 / (1.0 - transmittanceMax); + + // Log sampling + float transmittance = 1.0 - sample; + t = -log(transmittance) / sigmaT; + + // Set the pdf + pdf *= pdfVol * sigmaT * transmittance; + } + + return true; +} + +// Function responsible for volume scattering +void ComputeVolumeScattering(inout PathIntersection pathIntersection : SV_RayPayload, float3 inputSample, bool sampleLocalLights) +{ + // Reset the ray intersection color, which will store our final result + pathIntersection.value = 0.0; + +#ifdef HAS_LIGHTLOOP + + // Grab depth information + uint currentDepth = _RaytracingMaxRecursion - pathIntersection.remainingDepth; + + // Check if we want to compute direct and emissive lighting for current depth + bool computeDirect = currentDepth >= _RaytracingMinRecursion - 1; + + // Compute the scattering position + float3 scatteringPosition = WorldRayOrigin() + pathIntersection.t * WorldRayDirection(); + + // Create the list of active lights + LightList lightList = CreateLightList(scatteringPosition, sampleLocalLights); + + // Bunch of variables common to material and light sampling + float pdf; + float3 value; + + RayDesc ray; + ray.Origin = scatteringPosition; + ray.TMin = 0.0; + + PathIntersection nextPathIntersection; + + // Light sampling + if (computeDirect) + { + if (SampleLights(lightList, inputSample.xyz, scatteringPosition, 0.0, ray.Direction, value, pdf, ray.TMax)) + { + // FIXME: Apply phase function and divide by pdf (only isotropic for now, and not sure about sigmaS value) + value *= _HeightFogBaseScattering.xyz * ComputeHeightFogMultiplier(scatteringPosition.y) * INV_FOUR_PI / pdf; + + if (Luminance(value) > 0.001) + { + // Shoot a transmission ray (to mark it as such, purposedly set remaining depth to an invalid value) + nextPathIntersection.remainingDepth = _RaytracingMaxRecursion + 1; + ray.TMax -= _RaytracingRayBias; + nextPathIntersection.value = 1.0; + + // FIXME: For the time being, we choose not to apply any back/front-face culling for shadows, will possibly change in the future + TraceRay(_RaytracingAccelerationStructure, RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_FORCE_NON_OPAQUE | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER, + RAYTRACINGRENDERERFLAG_CAST_SHADOW, 0, 1, 1, ray, nextPathIntersection); + + pathIntersection.value += value * nextPathIntersection.value; + } + } + } + +#endif // HAS_LIGHTLOOP +} + +#endif // UNITY_PATH_TRACING_VOLUME_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl.meta new file mode 100644 index 00000000000..8a69440686d --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e7afdfa6d79198541bc5a99fd0d71575 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl index d48a8e20302..52beb2ad5a8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl @@ -1,5 +1,5 @@ -#ifndef UNITY_RAY_TRACING_VOLUME_INCLUDED -#define UNITY_RAY_TRACING_VOLUME_INCLUDED +#ifndef UNITY_ATMOSPHERIC_SCATTERING_RAY_TRACING_INCLUDED +#define UNITY_ATMOSPHERIC_SCATTERING_RAY_TRACING_INCLUDED #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl" @@ -10,7 +10,11 @@ void ApplyFogAttenuation(float3 origin, float3 direction, float t, inout float3 float dist = min(t, _MaxFogDistance); float absFogBaseHeight = _HeightFogBaseHeight; float fogTransmittance = TransmittanceHeightFog(_HeightFogBaseExtinction, absFogBaseHeight, _HeightFogExponents, direction.y, origin.y, dist); - float3 fogColor = useFogColor ? GetFogColor(-direction, dist) : 0.0; + + // This is designed to match the raster volumes... even though I'm not sure why it's working that way + float3 fogColor = useFogColor && !_EnableVolumetricFog ? + GetFogColor(-direction, dist) * _HeightFogBaseScattering.xyz / _HeightFogBaseExtinction : + 0.0; value = lerp(fogColor, value, fogTransmittance); } } @@ -22,8 +26,13 @@ void ApplyFogAttenuation(float3 origin, float3 direction, inout float3 value) float dist = min(_MipFogFar, _MaxFogDistance); float absFogBaseHeight = _HeightFogBaseHeight; float fogTransmittance = TransmittanceHeightFog(_HeightFogBaseExtinction, absFogBaseHeight, _HeightFogExponents, direction.y, origin.y, dist); - value = lerp(GetFogColor(-direction, dist), value, fogTransmittance); + + // This is designed to match the raster volumes... even though I'm not sure why it's working that way + float3 fogColor = !_EnableVolumetricFog ? + GetFogColor(-direction, dist) * _HeightFogBaseScattering.xyz / _HeightFogBaseExtinction : + 0.0; + value = lerp(fogColor, value, fogTransmittance); } } -#endif // UNITY_RAY_TRACING_VOLUME_INCLUDED +#endif // UNITY_ATMOSPHERIC_SCATTERING_RAY_TRACING_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl index 054ab42dd40..02ab9bfc027 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl @@ -21,13 +21,13 @@ float2 ScramblingValueFloat2(uint2 pixelCoord) uint ScramblingValueUInt(uint2 pixelCoord) { pixelCoord = pixelCoord & 255; - return clamp((uint)(_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)].x * 256.0f), 0, 255); + return clamp((uint)(_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)].x * 256.0), 0, 255); } uint2 ScramblingValueUInt2(uint2 pixelCoord) { pixelCoord = pixelCoord & 255; - return clamp((uint2)(_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)] * 256.0f), uint2(0,0), uint2(255, 255)); + return clamp((uint2)(_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)] * 256.0), uint2(0,0), uint2(255, 255)); } // Wrapper to sample the scrambled low Low-Discrepancy sequence (returns a float) @@ -49,7 +49,7 @@ uint GetLDSequenceSampleUInt(uint sampleIndex, uint sampleDimension) // sampleDimension = sampleDimension & 255; // Fetch the sequence value and return it - return clamp((uint)(_OwenScrambledTexture[uint2(sampleDimension, sampleIndex)] * 256.0f), 0, 255); + return clamp((uint)(_OwenScrambledTexture[uint2(sampleDimension, sampleIndex)] * 256.0), 0, 255); } // This is an implementation of the method from the paper @@ -63,17 +63,18 @@ float GetBNDSequenceSample(uint2 pixelCoord, uint sampleIndex, uint sampleDimens // xor index based on optimized ranking uint rankingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7); - uint rankedSampleIndex = sampleIndex ^ clamp((uint)(_RankingTileXSPP[uint2(rankingIndex & 127, rankingIndex / 128)] * 256.0f), 0, 255); + uint rankedSampleIndex = sampleIndex ^ clamp((uint)(_RankingTileXSPP[uint2(rankingIndex & 127, rankingIndex / 128)] * 256.0), 0, 255); // fetch value in sequence - uint value = clamp((uint)(_OwenScrambledTexture[uint2(sampleDimension, rankedSampleIndex.x)] * 256.0f), 0, 255); + uint value = clamp((uint)(_OwenScrambledTexture[uint2(sampleDimension, rankedSampleIndex.x)] * 256.0), 0, 255); // If the dimension is optimized, xor sequence value based on optimized scrambling uint scramblingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7); - value = value ^ clamp((uint)(_ScramblingTileXSPP[uint2(scramblingIndex & 127, scramblingIndex / 128)] * 256.0f), 0, 255); + float scramblingValue = min(_ScramblingTileXSPP[uint2(scramblingIndex & 127, scramblingIndex / 128)], 0.999); + value = value ^ uint(scramblingValue * 256.0); - // convert to float and return - return (0.5f + value) / 256.0f; + // Convert to float (to avoid the same 1/256th quantization everywhere, we jitter by the pixel scramblingValue) + return (scramblingValue + value) / 256.0; } #endif // UNITY_RAYTRACING_SAMPLING_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl index 82945c8d966..9a468a33ff4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl @@ -1,15 +1,13 @@ // Ray tracing includes #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingFragInputs.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RayTracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl" // Path tracing includes #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingIntersection.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl" - +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingVolume.hlsl" #ifdef HAS_LIGHTLOOP #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingLight.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl" #endif float PowerHeuristic(float f, float b) @@ -22,20 +20,9 @@ float3 GetPositionBias(float3 geomNormal, float bias, bool below) return geomNormal * (below ? -bias : bias); } -// Generic function that handles the reflection code -[shader("closesthit")] -void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) +// Function responsible for surface scattering +void ComputeSurfaceScattering(inout PathIntersection pathIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes, float4 inputSample) { - // Always set the new t value - pathIntersection.t = RayTCurrent(); - - // If the max depth has been reached, bail out - if (!pathIntersection.remainingDepth) - { - pathIntersection.value = 0.0; - return; - } - // The first thing that we should do is grab the intersection vertex IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); @@ -57,7 +44,7 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu // Make sure to add the additional travel distance pathIntersection.cone.width += pathIntersection.t * abs(pathIntersection.cone.spreadAngle); -#ifndef HAS_LIGHTLOOP +#ifdef SHADER_UNLIT // This is quick and dirty way to avoid double contribution from light meshes if (currentDepth) pathIntersection.cone.spreadAngle = -1.0; @@ -86,17 +73,11 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu // Compute the bsdf data BSDFData bsdfData = ConvertSurfaceDataToBSDFData(posInput.positionSS, surfaceData); -#ifdef HAS_LIGHTLOOP +#ifndef SHADER_UNLIT // Let's compute the world space position (the non-camera relative one if camera relative rendering is enabled) float3 shadingPosition = fragInput.positionRWS; - // Generate the new sample (following values of the sequence) - float3 inputSample = 0.0; - inputSample.x = GetSample(pathIntersection.pixelCoord, _RaytracingSampleIndex, 4 * currentDepth); - inputSample.y = GetSample(pathIntersection.pixelCoord, _RaytracingSampleIndex, 4 * currentDepth + 1); - inputSample.z = GetSample(pathIntersection.pixelCoord, _RaytracingSampleIndex, 4 * currentDepth + 2); - // Get current path throughput float3 pathThroughput = pathIntersection.value; @@ -108,7 +89,12 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu if (CreateMaterialData(pathIntersection, builtinData, bsdfData, shadingPosition, inputSample.z, mtlData)) { // Create the list of active lights - LightList lightList = CreateLightList(shadingPosition, mtlData.bsdfData.geomNormalWS, builtinData.renderingLayers); + #ifdef _SURFACE_TYPE_TRANSPARENT + float3 lightNormal = 0.0; + #else + float3 lightNormal = mtlData.bsdfData.geomNormalWS; + #endif + LightList lightList = CreateLightList(shadingPosition, lightNormal, builtinData.renderingLayers); // Bunch of variables common to material and light sampling float pdf; @@ -124,7 +110,7 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu // Light sampling if (computeDirect) { - if (SampleLights(lightList, inputSample, rayDescriptor.Origin, mtlData.bsdfData.normalWS, rayDescriptor.Direction, value, pdf, rayDescriptor.TMax)) + if (SampleLights(lightList, inputSample.xyz, rayDescriptor.Origin, mtlData.bsdfData.normalWS, rayDescriptor.Direction, value, pdf, rayDescriptor.TMax)) { EvaluateMaterial(mtlData, rayDescriptor.Direction, mtlResult); @@ -147,7 +133,7 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu } // Material sampling - if (SampleMaterial(mtlData, inputSample, rayDescriptor.Direction, mtlResult)) + if (SampleMaterial(mtlData, inputSample.xyz, rayDescriptor.Direction, mtlResult)) { // Compute overall material value and pdf pdf = mtlResult.diffPdf + mtlResult.specPdf; @@ -158,9 +144,8 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu // Apply Russian roulette to our path const float rrThreshold = 0.2 + 0.1 * _RaytracingMaxRecursion; float rrFactor, rrValue = Luminance(pathThroughput); - float rrSample = GetSample(pathIntersection.pixelCoord, _RaytracingSampleIndex, 4 * currentDepth + 3); - if (RussianRouletteTest(rrThreshold, rrValue, rrSample, rrFactor, !currentDepth)) + if (RussianRouletteTest(rrThreshold, rrValue, inputSample.w, rrFactor, !currentDepth)) { bool isSampleBelow = IsBelow(mtlData, rayDescriptor.Direction); @@ -206,7 +191,7 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu } } -#else // HAS_LIGHTLOOP +#else // SHADER_UNLIT pathIntersection.value = (!currentDepth || computeDirect) ? bsdfData.color * GetInverseCurrentExposureMultiplier() + builtinData.emissiveColor : 0.0; @@ -229,8 +214,61 @@ void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, Attribu } #endif +#endif // SHADER_UNLIT +} + +// Generic function that handles one scattering event (a vertex along the full path), can be either: +// - Surface scattering +// - Volume scattering +[shader("closesthit")] +void ClosestHit(inout PathIntersection pathIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) +{ + // Always set the new t value + pathIntersection.t = RayTCurrent(); + + // If the max depth has been reached, bail out + if (!pathIntersection.remainingDepth) + { + pathIntersection.value = 0.0; + return; + } + + // Grab depth information + int currentDepth = _RaytracingMaxRecursion - pathIntersection.remainingDepth; + + float4 inputSample = 0.0; + +#ifdef HAS_LIGHTLOOP + + float pdf = 1.0; + bool sampleLocalLights, sampleVolume = false; + + if (currentDepth >= 0) + { + // Generate a 4D unit-square sample for this depth, from our QMC sequence + inputSample = GetSample4D(pathIntersection.pixelCoord, _RaytracingSampleIndex, 4 * currentDepth); + + // For the time being, we test for volumetric scattering only on camera rays + if (!currentDepth) + sampleVolume = SampleVolumeScatteringPosition(inputSample.w, pathIntersection.t, pdf, sampleLocalLights); + } + + if (sampleVolume) + ComputeVolumeScattering(pathIntersection, inputSample.xyz, sampleLocalLights); + else + ComputeSurfaceScattering(pathIntersection, attributeData, inputSample); + + // Apply the volume/surface pdf + pathIntersection.value /= pdf; + +#else // HAS_LIGHTLOOP + + ComputeSurfaceScattering(pathIntersection, attributeData, inputSample); + #endif // HAS_LIGHTLOOP + // Apply volumetric attenuation + bool computeDirect = currentDepth >= _RaytracingMinRecursion - 1; ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.t, pathIntersection.value, computeDirect); if (currentDepth)