diff --git a/.yamato/all-hdrp.yml b/.yamato/all-hdrp.yml index bcb269c68f6..7b3a07ce8e0 100644 --- a/.yamato/all-hdrp.yml +++ b/.yamato/all-hdrp.yml @@ -12,7 +12,7 @@ All_HDRP_trunk: rerun: on-new-revision - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_XR_trunk rerun: on-new-revision - - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_RenderGraph_trunk + - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_NonRenderGraph_trunk rerun: on-new-revision - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_Standalone_trunk rerun: on-new-revision @@ -40,7 +40,7 @@ All_HDRP_trunk: rerun: on-new-revision - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_trunk rerun: on-new-revision - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_trunk + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_trunk rerun: on-new-revision - path: .yamato/all-hdrp_hybrid.yml#All_HDRP_Hybrid_trunk rerun: on-new-revision @@ -53,7 +53,7 @@ All_HDRP_2020.2: rerun: on-new-revision - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_XR_2020.2 rerun: on-new-revision - - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_RenderGraph_2020.2 + - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_NonRenderGraph_2020.2 rerun: on-new-revision - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_Standalone_2020.2 rerun: on-new-revision @@ -81,7 +81,7 @@ All_HDRP_2020.2: rerun: on-new-revision - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_2020.2 rerun: on-new-revision - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_2020.2 + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_2020.2 rerun: on-new-revision - path: .yamato/all-hdrp_hybrid.yml#All_HDRP_Hybrid_2020.2 rerun: on-new-revision @@ -94,7 +94,7 @@ All_HDRP_CUSTOM-REVISION: rerun: always - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_XR_CUSTOM-REVISION rerun: always - - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_RenderGraph_CUSTOM-REVISION + - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_playmode_NonRenderGraph_CUSTOM-REVISION rerun: always - path: .yamato/hdrp-win-dx11.yml#HDRP_Win_DX11_Standalone_CUSTOM-REVISION rerun: always @@ -122,7 +122,7 @@ All_HDRP_CUSTOM-REVISION: rerun: always - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_CUSTOM-REVISION rerun: always - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_CUSTOM-REVISION rerun: always - path: .yamato/all-hdrp_hybrid.yml#All_HDRP_Hybrid_CUSTOM-REVISION rerun: always diff --git a/.yamato/all-hdrp_dxr.yml b/.yamato/all-hdrp_dxr.yml index a3c0924b626..39fda112785 100644 --- a/.yamato/all-hdrp_dxr.yml +++ b/.yamato/all-hdrp_dxr.yml @@ -12,7 +12,7 @@ All_HDRP_DXR_trunk: rerun: on-new-revision - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_trunk rerun: on-new-revision - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_trunk + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_trunk rerun: on-new-revision All_HDRP_DXR_2020.2: name: All HDRP_DXR CI - 2020.2 @@ -23,7 +23,7 @@ All_HDRP_DXR_2020.2: rerun: on-new-revision - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_2020.2 rerun: on-new-revision - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_2020.2 + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_2020.2 rerun: on-new-revision All_HDRP_DXR_CUSTOM-REVISION: name: All HDRP_DXR CI - CUSTOM-REVISION @@ -34,7 +34,7 @@ All_HDRP_DXR_CUSTOM-REVISION: rerun: always - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_XR_CUSTOM-REVISION rerun: always - - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION + - path: .yamato/hdrp_dxr-win-dx12.yml#HDRP_DXR_Win_DX12_playmode_NonRenderGraph_CUSTOM-REVISION rerun: always variables: CUSTOM_REVISION: custom_revision_not_set diff --git a/.yamato/config/hdrp.metafile b/.yamato/config/hdrp.metafile index c3c964c3436..833ad0ab379 100644 --- a/.yamato/config/hdrp.metafile +++ b/.yamato/config/hdrp.metafile @@ -9,9 +9,9 @@ test_platforms: extra_utr_flags: - --extra-editor-arg="-xr-tests" - type: playmode - name: playmode_RenderGraph + name: playmode_NonRenderGraph extra_utr_flags: - - --extra-editor-arg="-rendergraph-tests" + - --extra-editor-arg="-non-rendergraph-tests" - type: editmode - type: Standalone timeout: @@ -58,7 +58,7 @@ all: - editmode - playmode - playmode_XR - - playmode_RenderGraph + - playmode_NonRenderGraph - Standalone - platform: Win api: DX12 @@ -89,6 +89,6 @@ all: test_platforms: - playmode - playmode_XR - - playmode_RenderGraph + - playmode_NonRenderGraph - project: HDRP_Hybrid all: true diff --git a/.yamato/config/hdrp_dxr.metafile b/.yamato/config/hdrp_dxr.metafile index 1f585d16de9..1465be45056 100644 --- a/.yamato/config/hdrp_dxr.metafile +++ b/.yamato/config/hdrp_dxr.metafile @@ -9,9 +9,9 @@ test_platforms: extra_utr_flags: - --extra-editor-arg="-xr-tests" - type: playmode - name: playmode_RenderGraph + name: playmode_NonRenderGraph extra_utr_flags: - - --extra-editor-arg="-rendergraph-tests" + - --extra-editor-arg="-non-rendergraph-tests" platforms: - name: Win apis: @@ -31,5 +31,5 @@ all: - Standalone - playmode - playmode_XR - - playmode_RenderGraph + - playmode_NonRenderGraph diff --git a/.yamato/hdrp-linux-vulkan.yml b/.yamato/hdrp-linux-vulkan.yml index e034bfe3424..b4ae284be5a 100644 --- a/.yamato/hdrp-linux-vulkan.yml +++ b/.yamato/hdrp-linux-vulkan.yml @@ -22,8 +22,8 @@ HDRP_Linux_Vulkan_playmode_trunk: logs: paths: - "**/test-results/**" -HDRP_Linux_Vulkan_playmode_RenderGraph_trunk: - name: HDRP on Linux_Vulkan_playmode_RenderGraph on version trunk +HDRP_Linux_Vulkan_playmode_NonRenderGraph_trunk: + name: HDRP on Linux_Vulkan_playmode_NonRenderGraph on version trunk agent: type: Unity::VM::GPU image: cds-ops/ubuntu-18.04-base:stable @@ -36,7 +36,7 @@ HDRP_Linux_Vulkan_playmode_RenderGraph_trunk: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr --output TestProjects/HDRP_Tests/utr - chmod +x TestProjects/HDRP_Tests/utr - cd TestProjects/HDRP_Tests && sudo unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: @@ -98,8 +98,8 @@ HDRP_Linux_Vulkan_playmode_2020.2: logs: paths: - "**/test-results/**" -HDRP_Linux_Vulkan_playmode_RenderGraph_2020.2: - name: HDRP on Linux_Vulkan_playmode_RenderGraph on version 2020.2 +HDRP_Linux_Vulkan_playmode_NonRenderGraph_2020.2: + name: HDRP on Linux_Vulkan_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::VM::GPU image: cds-ops/ubuntu-18.04-base:stable @@ -112,7 +112,7 @@ HDRP_Linux_Vulkan_playmode_RenderGraph_2020.2: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr --output TestProjects/HDRP_Tests/utr - chmod +x TestProjects/HDRP_Tests/utr - cd TestProjects/HDRP_Tests && sudo unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: @@ -178,8 +178,8 @@ HDRP_Linux_Vulkan_playmode_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:linux rerun: always -HDRP_Linux_Vulkan_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP on Linux_Vulkan_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_Linux_Vulkan_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP on Linux_Vulkan_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::VM::GPU image: cds-ops/ubuntu-18.04-base:stable @@ -193,7 +193,7 @@ HDRP_Linux_Vulkan_playmode_RenderGraph_CUSTOM-REVISION: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr --output TestProjects/HDRP_Tests/utr - chmod +x TestProjects/HDRP_Tests/utr - cd TestProjects/HDRP_Tests && sudo unity-downloader-cli --source-file ../../unity_revision.txt -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && DISPLAY=:0.0 ./utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: diff --git a/.yamato/hdrp-osx-metal.yml b/.yamato/hdrp-osx-metal.yml index d2fe7102983..942e64a618e 100644 --- a/.yamato/hdrp-osx-metal.yml +++ b/.yamato/hdrp-osx-metal.yml @@ -55,8 +55,8 @@ HDRP_OSX_Metal_playmode_XR_trunk: logs: paths: - "**/test-results/**" -HDRP_OSX_Metal_playmode_RenderGraph_trunk: - name: HDRP on OSX_Metal_playmode_RenderGraph on version trunk +HDRP_OSX_Metal_playmode_NonRenderGraph_trunk: + name: HDRP on OSX_Metal_playmode_NonRenderGraph on version trunk agent: type: Unity::metal::macmini image: slough-ops/macos-10.14-xcode:stable @@ -72,7 +72,7 @@ HDRP_OSX_Metal_playmode_RenderGraph_trunk: - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP '$(/usr/local/bin/python3 -m site --user-base)/bin/unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only' - |5- - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests"" + ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests"" UTR_RESULT=$? mkdir -p TestProjects/HDRP_Tests/test-results/ scp -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" -r bokken@$BOKKEN_DEVICE_IP:/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results/ TestProjects/HDRP_Tests/test-results/ @@ -159,8 +159,8 @@ HDRP_OSX_Metal_playmode_XR_2020.2: logs: paths: - "**/test-results/**" -HDRP_OSX_Metal_playmode_RenderGraph_2020.2: - name: HDRP on OSX_Metal_playmode_RenderGraph on version 2020.2 +HDRP_OSX_Metal_playmode_NonRenderGraph_2020.2: + name: HDRP on OSX_Metal_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::metal::macmini image: slough-ops/macos-10.14-xcode:stable @@ -176,7 +176,7 @@ HDRP_OSX_Metal_playmode_RenderGraph_2020.2: - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP '$(/usr/local/bin/python3 -m site --user-base)/bin/unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only' - |5- - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests"" + ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests"" UTR_RESULT=$? mkdir -p TestProjects/HDRP_Tests/test-results/ scp -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" -r bokken@$BOKKEN_DEVICE_IP:/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results/ TestProjects/HDRP_Tests/test-results/ @@ -271,8 +271,8 @@ HDRP_OSX_Metal_playmode_XR_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:macos rerun: always -HDRP_OSX_Metal_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP on OSX_Metal_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_OSX_Metal_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP on OSX_Metal_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::metal::macmini image: slough-ops/macos-10.14-xcode:stable @@ -289,7 +289,7 @@ HDRP_OSX_Metal_playmode_RenderGraph_CUSTOM-REVISION: - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP '$(/usr/local/bin/python3 -m site --user-base)/bin/unity-downloader-cli --source-file ~/Graphics/unity_revision.txt -c editor -c il2cpp --wait --published-only' - |5- - ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests"" + ssh -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" bokken@$BOKKEN_DEVICE_IP "export UPM_REGISTRY=https://artifactory-slo.bf.unity3d.com/artifactory/api/npm/upm-candidates; echo \$UPM_REGISTRY; cd ~/Graphics/TestProjects/HDRP_Tests && ~/Graphics/TestProjects/HDRP_Tests/utr --suite=playmode --testproject=/Users/bokken/Graphics/TestProjects/HDRP_Tests --editor-location=/Users/bokken/.Editor --artifacts_path=/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests"" UTR_RESULT=$? mkdir -p TestProjects/HDRP_Tests/test-results/ scp -i ~/.ssh/id_rsa_macmini -o "StrictHostKeyChecking=no" -r bokken@$BOKKEN_DEVICE_IP:/Users/bokken/Graphics/TestProjects/HDRP_Tests/test-results/ TestProjects/HDRP_Tests/test-results/ diff --git a/.yamato/hdrp-win-dx11.yml b/.yamato/hdrp-win-dx11.yml index fe68cc2fe6e..f4ca1977768 100644 --- a/.yamato/hdrp-win-dx11.yml +++ b/.yamato/hdrp-win-dx11.yml @@ -39,8 +39,8 @@ HDRP_Win_DX11_playmode_XR_trunk: logs: paths: - "**/test-results/**" -HDRP_Win_DX11_playmode_RenderGraph_trunk: - name: HDRP on Win_DX11_playmode_RenderGraph on version trunk +HDRP_Win_DX11_playmode_NonRenderGraph_trunk: + name: HDRP on Win_DX11_playmode_NonRenderGraph on version trunk agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -52,7 +52,7 @@ HDRP_Win_DX11_playmode_RenderGraph_trunk: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d11" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d11" artifacts: logs: paths: @@ -151,8 +151,8 @@ HDRP_Win_DX11_playmode_XR_2020.2: logs: paths: - "**/test-results/**" -HDRP_Win_DX11_playmode_RenderGraph_2020.2: - name: HDRP on Win_DX11_playmode_RenderGraph on version 2020.2 +HDRP_Win_DX11_playmode_NonRenderGraph_2020.2: + name: HDRP on Win_DX11_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -164,7 +164,7 @@ HDRP_Win_DX11_playmode_RenderGraph_2020.2: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d11" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d11" artifacts: logs: paths: @@ -271,8 +271,8 @@ HDRP_Win_DX11_playmode_XR_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:windows rerun: always -HDRP_Win_DX11_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP on Win_DX11_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_Win_DX11_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP on Win_DX11_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -285,7 +285,7 @@ HDRP_Win_DX11_playmode_RenderGraph_CUSTOM-REVISION: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli --source-file ../../unity_revision.txt -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d11" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d11" artifacts: logs: paths: diff --git a/.yamato/hdrp-win-dx12.yml b/.yamato/hdrp-win-dx12.yml index 822d7fdcbeb..4e51665bbc5 100644 --- a/.yamato/hdrp-win-dx12.yml +++ b/.yamato/hdrp-win-dx12.yml @@ -39,8 +39,8 @@ HDRP_Win_DX12_playmode_XR_trunk: logs: paths: - "**/test-results/**" -HDRP_Win_DX12_playmode_RenderGraph_trunk: - name: HDRP on Win_DX12_playmode_RenderGraph on version trunk +HDRP_Win_DX12_playmode_NonRenderGraph_trunk: + name: HDRP on Win_DX12_playmode_NonRenderGraph on version trunk agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -52,7 +52,7 @@ HDRP_Win_DX12_playmode_RenderGraph_trunk: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: @@ -151,8 +151,8 @@ HDRP_Win_DX12_playmode_XR_2020.2: logs: paths: - "**/test-results/**" -HDRP_Win_DX12_playmode_RenderGraph_2020.2: - name: HDRP on Win_DX12_playmode_RenderGraph on version 2020.2 +HDRP_Win_DX12_playmode_NonRenderGraph_2020.2: + name: HDRP on Win_DX12_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -164,7 +164,7 @@ HDRP_Win_DX12_playmode_RenderGraph_2020.2: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: @@ -271,8 +271,8 @@ HDRP_Win_DX12_playmode_XR_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:windows rerun: always -HDRP_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP on Win_DX12_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_Win_DX12_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP on Win_DX12_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -285,7 +285,7 @@ HDRP_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli --source-file ../../unity_revision.txt -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: diff --git a/.yamato/hdrp-win-vulkan.yml b/.yamato/hdrp-win-vulkan.yml index aca7d58f994..3f9dcb0ff77 100644 --- a/.yamato/hdrp-win-vulkan.yml +++ b/.yamato/hdrp-win-vulkan.yml @@ -39,8 +39,8 @@ HDRP_Win_Vulkan_playmode_XR_trunk: logs: paths: - "**/test-results/**" -HDRP_Win_Vulkan_playmode_RenderGraph_trunk: - name: HDRP on Win_Vulkan_playmode_RenderGraph on version trunk +HDRP_Win_Vulkan_playmode_NonRenderGraph_trunk: + name: HDRP on Win_Vulkan_playmode_NonRenderGraph on version trunk agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -52,7 +52,7 @@ HDRP_Win_Vulkan_playmode_RenderGraph_trunk: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: @@ -151,8 +151,8 @@ HDRP_Win_Vulkan_playmode_XR_2020.2: logs: paths: - "**/test-results/**" -HDRP_Win_Vulkan_playmode_RenderGraph_2020.2: - name: HDRP on Win_Vulkan_playmode_RenderGraph on version 2020.2 +HDRP_Win_Vulkan_playmode_NonRenderGraph_2020.2: + name: HDRP on Win_Vulkan_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -164,7 +164,7 @@ HDRP_Win_Vulkan_playmode_RenderGraph_2020.2: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: @@ -271,8 +271,8 @@ HDRP_Win_Vulkan_playmode_XR_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:windows rerun: always -HDRP_Win_Vulkan_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP on Win_Vulkan_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_Win_Vulkan_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP on Win_Vulkan_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -285,7 +285,7 @@ HDRP_Win_Vulkan_playmode_RenderGraph_CUSTOM-REVISION: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_Tests && unity-downloader-cli --source-file ../../unity_revision.txt -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-vulkan" + - cd TestProjects/HDRP_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-vulkan" artifacts: logs: paths: diff --git a/.yamato/hdrp_dxr-win-dx12.yml b/.yamato/hdrp_dxr-win-dx12.yml index bd67b6490b6..9c51e7dcb77 100644 --- a/.yamato/hdrp_dxr-win-dx12.yml +++ b/.yamato/hdrp_dxr-win-dx12.yml @@ -80,8 +80,8 @@ HDRP_DXR_Win_DX12_playmode_XR_trunk: logs: paths: - "**/test-results/**" -HDRP_DXR_Win_DX12_playmode_RenderGraph_trunk: - name: HDRP_DXR on Win_DX12_playmode_RenderGraph on version trunk +HDRP_DXR_Win_DX12_playmode_NonRenderGraph_trunk: + name: HDRP_DXR on Win_DX12_playmode_NonRenderGraph on version trunk agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -93,7 +93,7 @@ HDRP_DXR_Win_DX12_playmode_RenderGraph_trunk: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_DXR_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_DXR_Tests && unity-downloader-cli -u dc4a46d1cb369a5194a18beceb09063206b35c43 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: @@ -175,8 +175,8 @@ HDRP_DXR_Win_DX12_playmode_XR_2020.2: logs: paths: - "**/test-results/**" -HDRP_DXR_Win_DX12_playmode_RenderGraph_2020.2: - name: HDRP_DXR on Win_DX12_playmode_RenderGraph on version 2020.2 +HDRP_DXR_Win_DX12_playmode_NonRenderGraph_2020.2: + name: HDRP_DXR on Win_DX12_playmode_NonRenderGraph on version 2020.2 agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -188,7 +188,7 @@ HDRP_DXR_Win_DX12_playmode_RenderGraph_2020.2: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_DXR_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_DXR_Tests && unity-downloader-cli -u 24a0f8b56f72092c87d71cefbe3c26d3d6f4f6e9 -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: @@ -285,8 +285,8 @@ HDRP_DXR_Win_DX12_playmode_XR_CUSTOM-REVISION: dependencies: - path: .yamato/_editor_priming.yml#editor:priming:CUSTOM-REVISION:windows rerun: always -HDRP_DXR_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION: - name: HDRP_DXR on Win_DX12_playmode_RenderGraph on version CUSTOM-REVISION +HDRP_DXR_Win_DX12_playmode_NonRenderGraph_CUSTOM-REVISION: + name: HDRP_DXR on Win_DX12_playmode_NonRenderGraph on version CUSTOM-REVISION agent: type: Unity::VM::GPU image: graphics-foundation/win10-dxr:stable @@ -299,7 +299,7 @@ HDRP_DXR_Win_DX12_playmode_RenderGraph_CUSTOM-REVISION: - curl -s https://artifactory.internal.unity3d.com/core-automation/tools/utr-standalone/utr.bat --output TestProjects/HDRP_DXR_Tests/utr.bat - pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - cd TestProjects/HDRP_DXR_Tests && unity-downloader-cli --source-file ../../unity_revision.txt -c editor -c il2cpp --wait --published-only - - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-rendergraph-tests" --extra-editor-arg="-force-d3d12" + - cd TestProjects/HDRP_DXR_Tests && utr --suite=playmode --testproject=. --editor-location=.Editor --artifacts_path=test-results --reruncount=2 --extra-editor-arg="-non-rendergraph-tests" --extra-editor-arg="-force-d3d12" artifacts: logs: paths: diff --git a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity index a4d3f91a968..61316daf730 100644 --- a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity +++ b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4052_TAA.unity @@ -4420,7 +4420,7 @@ PrefabInstance: - target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3} propertyPath: xrThresholdMultiplier - value: 1.5 + value: 1.6 objectReference: {fileID: 0} - target: {fileID: 114995348509370400, guid: c07ace9ab142ca9469fa377877c2f1e7, type: 3} diff --git a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9901_AOV_buffers/AovOutput.cs b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9901_AOV_buffers/AovOutput.cs index cc991dd73d9..8a7e3661d45 100644 --- a/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9901_AOV_buffers/AovOutput.cs +++ b/TestProjects/HDRP_Tests/Assets/GraphicTests/Scenes/9x_Other/9901_AOV_buffers/AovOutput.cs @@ -117,6 +117,15 @@ AOVRequestDataCollection BuildAovRequest() ).Build(); } + void OnDisable() + { + RTHandles.Release(_rt.output); + RTHandles.Release(_rt.color); + RTHandles.Release(_rt.depth); + RTHandles.Release(_rt.normal); + RTHandles.Release(_rt.motionvector); + } + void Start() { GetComponent().SetAOVRequests(BuildAovRequest()); diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_a.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_a.png index 981fc7ccb1f..4f38f80f606 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_a.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_a.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e45e4b1c3e5f34c9d74e7bdafa0068df148df97ea17d973a23c9873387670d5e -size 237826 +oid sha256:1ab13e322c857384d29581d4f5e7dc2344458601b505ccd63c609b3b9cbe38d6 +size 248654 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_b.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_b.png index 7d328dea026..40b37677aba 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_b.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1303_StackLitSG_Testers_b.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:619e8b7d51809b4b9faaa99b6669450dfe2886b9ba2d4b76f697331650836bfc -size 264539 +oid sha256:469857bef2f12f3b24b98970eb3125264669d8440398df615a2e9f3c307d380b +size 277997 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1501_EyeTestSG.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1501_EyeTestSG.png index 7cf1d73c307..21e81ece8a9 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1501_EyeTestSG.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/1501_EyeTestSG.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1c2bf72c163965563b0a5dd51d131304fe25cfb6230eecde328ddc24a9c6780 -size 127138 +oid sha256:1865ed7f9ea0104218196f641c970407b582ca82424fcd730fa45a8e9bcce9d8 +size 139848 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2204_ReflectionProbes_Lights.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2204_ReflectionProbes_Lights.png index 837737e0782..e1032dfea07 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2204_ReflectionProbes_Lights.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2204_ReflectionProbes_Lights.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8b276b9d47c142761d3b73e53446ba1b7a7a3d7628629b1972c54518f081445b -size 40489 +oid sha256:55ea2ee1127f6edbc7b0cf40ac8bf1cfee3e7ac7b4e0d11134bc746562a20795 +size 45156 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2305_Contact_Shadow_PointLight.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2305_Contact_Shadow_PointLight.png index 0db9cc11ae7..32b7a3b00fb 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2305_Contact_Shadow_PointLight.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2305_Contact_Shadow_PointLight.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9793cfdb451273d2e96965f1775acb767815d9640fc5182c260f86a18a3d0d97 -size 11936 +oid sha256:d53feb80168ce1ff3465dcdc022b550a4fce96abd852c0cf2400d75d08c239f8 +size 146112 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2306_Contact_Shadow_SpotLight.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2306_Contact_Shadow_SpotLight.png index 54cb60c1870..0a5750d07ce 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2306_Contact_Shadow_SpotLight.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2306_Contact_Shadow_SpotLight.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:486b8ec690808ea10872b811355c1b43edb3c1baf81837a32015dba01b33fe1d -size 11923 +oid sha256:440c5130d0c7be57661f8f3372dac90085d9278bde7c9f1c12be302ede803841 +size 143862 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2311_ShadowMaps.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2311_ShadowMaps.png index be7b0661406..38fe7474bf9 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2311_ShadowMaps.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/2311_ShadowMaps.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:819994e69eb8e5c3a473ed3cdc1ddc3907a62869d1e28aa9a0f98157b718b127 -size 124457 +oid sha256:79bcbc7e44ef35983e89ecec5707f5c8673cbef5db36354e04439f0e817670b1 +size 178659 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5003_Fog_DensityVolumesShadows.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5003_Fog_DensityVolumesShadows.png index 6feff7c3684..1e9625dd55d 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5003_Fog_DensityVolumesShadows.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5003_Fog_DensityVolumesShadows.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ebe62a04958dff25b0461e43fbb668d191e483ad4bda110b336cb17220c5d7ed -size 106085 +oid sha256:f8960d432b7036b851fcecb1df3688be935170e74c0c8ce5b3a55365970d53a9 +size 107575 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9004_MultiViewport.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9004_MultiViewport.png index f186ee6dfe6..572ee3697c9 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9004_MultiViewport.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9004_MultiViewport.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b756114b2650b792acd32a37ff8881f25af2ba63373d2fd193509c3190aa2cc1 -size 112642 +oid sha256:2babc86b61aa9b3f633ad57179a0bb94df06aac1177c45a490e850e5dd9f2a3e +size 168579 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardBoth.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardBoth.png index 7ae4abef137..9658a485cfd 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardBoth.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardBoth.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa28088ccdd36a14ca35d7cbc44d4ddf09709667ad7a3ee4a8548db717078929 -size 134332 +oid sha256:ada3a1bc6d40c73c9ff811430068cbd45edb3c587a9593d9977698737a263580 +size 243546 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardOnly.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardOnly.png index 0b114ec5510..d762807fc1e 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardOnly.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9401_MSAAForwardOnly.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a40d948965426ff4603ce0bf20499ec73892130c373f3862a4e00d5bc1563ff -size 156342 +oid sha256:c305c887642c2551a67b6813590c36f3fa82024e04e59c59f5c4490fbdcc6463 +size 267981 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9701_CustomPass_DrawRenderers.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9701_CustomPass_DrawRenderers.png index 4a34755117f..543c3337443 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9701_CustomPass_DrawRenderers.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/9701_CustomPass_DrawRenderers.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:01ab7b22ff9e62b9cf89f4de8627bcf9bca5998b5959df6db8decec9fd1d2dc9 -size 57772 +oid sha256:638db820b2e4801bfaba3a8de57627c48c4db2b31edf0cd4ec7600585fe0cf01 +size 60207 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png index 22067db91e6..337facbd7c4 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75acf70675932afecc93cc306159709efc756ddfd178022d6845eb1354548ca2 -size 195239 +oid sha256:0e2ef1a6674cac364252eaaf750ec9a3eaed84ef386eb919eb988ccc885c3583 +size 195066 diff --git a/TestProjects/HDRP_Tests/Assets/Tests/TestFilters/TestCaseFilters.asset b/TestProjects/HDRP_Tests/Assets/Tests/TestFilters/TestCaseFilters.asset index fad841c41b7..205449798e4 100644 --- a/TestProjects/HDRP_Tests/Assets/Tests/TestFilters/TestCaseFilters.asset +++ b/TestProjects/HDRP_Tests/Assets/Tests/TestFilters/TestCaseFilters.asset @@ -79,22 +79,22 @@ MonoBehaviour: Reason: unstable on yamato - FilteredScene: {fileID: 0} FilteredScenes: - - {fileID: 102900000, guid: 100c0e304d8aba84186dcd9bf48e5b85, type: 3} + - {fileID: 102900000, guid: c59b82120d32fbf4d96793fb7e0ec339, type: 3} ColorSpace: 1 BuildPlatform: -2 GraphicsDevice: 16 XrSdk: StereoModes: 0 - Reason: Memory allocation test failed, 2 allocations detected. + Reason: With rendergraph - unstable on yamato - FilteredScene: {fileID: 0} FilteredScenes: - - {fileID: 102900000, guid: 3ac6122326e687b439415cfacaf7d48e, type: 3} + - {fileID: 102900000, guid: 100c0e304d8aba84186dcd9bf48e5b85, type: 3} ColorSpace: 1 BuildPlatform: -2 - GraphicsDevice: 18 + GraphicsDevice: 16 XrSdk: StereoModes: 0 - Reason: cause crash on sucessive XR test + Reason: Memory allocation test failed, 2 allocations detected. - FilteredScene: {fileID: 0} FilteredScenes: - {fileID: 102900000, guid: 7529f10e11b78924b9c1ee1727b1405f, type: 3} @@ -230,3 +230,12 @@ MonoBehaviour: XrSdk: StereoModes: 0 Reason: unstable on yamato + - FilteredScene: {fileID: 0} + FilteredScenes: + - {fileID: 102900000, guid: 86f8f2a99d6720b48abc19c684103d74, type: 3} + ColorSpace: 1 + BuildPlatform: -2 + GraphicsDevice: 21 + XrSdk: + StereoModes: 0 + Reason: unstable on yamato XR diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index f0e8bf24f37..8e396a8f15d 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [10.1.0] - 2019-08-04 -Version Updated -The version number for this package has increased due to a version update of a related graphics package. +### Added +- Added context options "Move to Top", "Move to Bottom", "Expand All" and "Collapse All" for volume components. ### Added - Added the support of input system V2 diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs index 20a4a5ad363..9b831a25c67 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs @@ -216,24 +216,48 @@ event Action IViewDisplayer.OnUpdateRequested StyleSheet styleSheet = null; StyleSheet styleSheetLight = null; - void OnEnable() + void ReloadStyleSheets() { - //Stylesheet - // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692). - // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets. - // Waiting for filter on stylesheet (case 1228706) to remove last error. - if (styleSheet == null || styleSheet.Equals(null)) + if(styleSheet == null || styleSheet.Equals(null)) { styleSheet = AssetDatabase.LoadAssetAtPath(Style.k_uss); - if (styleSheet != null && !styleSheet.Equals(null)) - rootVisualElement.styleSheets.Add(styleSheet); + if(styleSheet == null || styleSheet.Equals(null)) + { + //Debug.LogWarning("[LookDev] Could not load Stylesheet."); + return; + } } - if (!EditorGUIUtility.isProSkin && styleSheetLight != null && !styleSheetLight.Equals(null)) + + if(!rootVisualElement.styleSheets.Contains(styleSheet)) + rootVisualElement.styleSheets.Add(styleSheet); + + //Additively load Light Skin + if(!EditorGUIUtility.isProSkin) { - styleSheetLight = AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload); - if (styleSheetLight != null && !styleSheetLight.Equals(null)) + if(styleSheetLight == null || styleSheetLight.Equals(null)) + { + styleSheetLight = AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload); + if(styleSheetLight == null || styleSheetLight.Equals(null)) + { + //Debug.LogWarning("[LookDev] Could not load Light skin."); + return; + } + } + + if(!rootVisualElement.styleSheets.Contains(styleSheetLight)) rootVisualElement.styleSheets.Add(styleSheetLight); } + } + + void OnEnable() + { + //Stylesheet + // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692). + // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets. + // Waiting for filter on stylesheet (case 1228706) to remove last error. + // On Editor Skin change, OnEnable is called and stylesheets need to be reloaded (case 1278802). + if(EditorApplication.isUpdating) + ReloadStyleSheets(); //Call the open function to configure LookDev // in case the window where open when last editor session finished. @@ -694,14 +718,11 @@ void OnGUI() // rootVisualElement.styleSheets.Add(styleSheetLight); //} } - else - { - //deal with missing style when domain reload... - if (!rootVisualElement.styleSheets.Contains(styleSheet)) - rootVisualElement.styleSheets.Add(styleSheet); - if (!EditorGUIUtility.isProSkin && !rootVisualElement.styleSheets.Contains(styleSheetLight)) - rootVisualElement.styleSheets.Add(styleSheetLight); - } + if(EditorApplication.isUpdating) + return; + + //deal with missing style on domain reload... + ReloadStyleSheets(); OnUpdateRequestedInternal?.Invoke(); } diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index 9d57249a1b0..b4d4cfa8baa 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -265,15 +265,30 @@ void OnContextClick(Vector2 position, VolumeComponent targetComponent, int id) var menu = new GenericMenu(); if (id == 0) + { menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move Up")); + menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move to Top")); + } else + { + menu.AddItem(EditorGUIUtility.TrTextContent("Move to Top"), false, () => MoveComponent(id, -id)); menu.AddItem(EditorGUIUtility.TrTextContent("Move Up"), false, () => MoveComponent(id, -1)); + } if (id == m_Editors.Count - 1) + { + menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move to Bottom")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Move Down")); + } else + { + menu.AddItem(EditorGUIUtility.TrTextContent("Move to Bottom"), false, () => MoveComponent(id, (m_Editors.Count -1) - id)); menu.AddItem(EditorGUIUtility.TrTextContent("Move Down"), false, () => MoveComponent(id, 1)); + } + menu.AddSeparator(string.Empty); + menu.AddItem(EditorGUIUtility.TrTextContent("Collapse All"), false, () => CollapseComponents()); + menu.AddItem(EditorGUIUtility.TrTextContent("Expand All"), false, () => ExpandComponents()); menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TrTextContent("Reset"), false, () => ResetComponent(targetComponent.GetType(), id)); menu.AddItem(EditorGUIUtility.TrTextContent("Remove"), false, () => RemoveComponent(id)); @@ -419,11 +434,44 @@ internal void MoveComponent(int id, int offset) m_ComponentsProperty.MoveArrayElement(id, id + offset); m_SerializedObject.ApplyModifiedProperties(); + // We need to keep track of what was expanded before to set it afterwards. + bool targetExpanded = m_Editors[id + offset].baseProperty.isExpanded; + bool sourceExpanded = m_Editors[id].baseProperty.isExpanded; + // Move editors var prev = m_Editors[id + offset]; m_Editors[id + offset] = m_Editors[id]; m_Editors[id] = prev; + + // Set the expansion values + m_Editors[id + offset].baseProperty.isExpanded = targetExpanded; + m_Editors[id].baseProperty.isExpanded = sourceExpanded; + } + + internal void CollapseComponents() + { + // Move components + m_SerializedObject.Update(); + int numEditors = m_Editors.Count; + for (int i = 0; i < numEditors; ++i) + { + m_Editors[i].baseProperty.isExpanded = false; + } + m_SerializedObject.ApplyModifiedProperties(); + } + + internal void ExpandComponents() + { + // Move components + m_SerializedObject.Update(); + int numEditors = m_Editors.Count; + for (int i = 0; i < numEditors; ++i) + { + m_Editors[i].baseProperty.isExpanded = true; + } + m_SerializedObject.ApplyModifiedProperties(); } + static bool CanPaste(VolumeComponent targetComponent) { diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs index 5bdd082a57b..ba1380b66be 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs @@ -221,6 +221,8 @@ public void Reset(RenderGraphPass pass) DynamicArray m_CompiledPassInfos = new DynamicArray(); Stack m_CullingStack = new Stack(); + int m_ExecutionCount; + #region Public Interface /// @@ -263,12 +265,14 @@ public void Cleanup() } /// - /// Purge resources that have been used since last frame. - /// This need to be called once per frame to avoid over usage of GPU memory. + /// End frame processing. Purge resources that have been used since last frame and resets internal states. + /// This need to be called once per frame. /// - public void PurgeUnusedResources() + public void EndFrame() { - m_Resources.PurgeUnusedResources(); + //m_Resources.PurgeUnusedResources(); + m_DebugParameters.logFrameInformation = false; + m_DebugParameters.logResources = false; } /// @@ -412,9 +416,11 @@ public ComputeBufferDesc GetComputeBufferDesc(in ComputeBufferHandle computeBuff /// Parameters necessary for the render graph execution. public void Begin(in RenderGraphParameters parameters) { + m_ExecutionCount++; + m_Logger.Initialize(); - m_Resources.BeginRender(parameters.currentFrameIndex); + m_Resources.BeginRender(parameters.currentFrameIndex, m_ExecutionCount); m_RenderGraphContext.cmd = parameters.commandBuffer; m_RenderGraphContext.renderContext = parameters.scriptableRenderContext; @@ -478,9 +484,6 @@ public void Execute() if (m_DebugParameters.logFrameInformation || m_DebugParameters.logResources) Debug.Log(m_Logger.GetLog()); - m_DebugParameters.logFrameInformation = false; - m_DebugParameters.logResources = false; - m_Resources.EndRender(); InvalidateContext(); @@ -1228,6 +1231,7 @@ public struct RenderGraphProfilingScope : IDisposable /// /// Profiling Scope constructor /// + /// Render Graph used for this scope. /// Profiling Sampler to be used for this scope. public RenderGraphProfilingScope(RenderGraph renderGraph, ProfilingSampler sampler) { diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphObjectPool.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphObjectPool.cs index 49e05a78da2..a69920a053c 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphObjectPool.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphObjectPool.cs @@ -88,14 +88,14 @@ internal void ReleaseAllTempAlloc() // Regular pooling API. Only internal use for now internal T Get() where T : new() { - var toto = SharedObjectPool.sharedPool; - return toto.Get(); + var pool = SharedObjectPool.sharedPool; + return pool.Get(); } internal void Release(T value) where T : new() { - var toto = SharedObjectPool.sharedPool; - toto.Release(value); + var pool = SharedObjectPool.sharedPool; + pool.Release(value); } } } diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs index 61fdcfc8cc4..da06a60d979 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs @@ -56,7 +56,7 @@ public virtual bool IsCreated() } #region Resources - [DebuggerDisplay("Resource ({ResType}:{GetName()})")] + [DebuggerDisplay("Resource ({GetType().Name}:{GetName()})")] class RenderGraphResource : IRenderGraphResource where DescType : struct @@ -117,6 +117,7 @@ internal RendererListResource(in RendererListDesc desc) DynamicArray[] m_Resources = new DynamicArray[(int)RenderGraphResourceType.Count]; TexturePool m_TexturePool = new TexturePool(); + int m_TextureCreationIndex; ComputeBufferPool m_ComputeBufferPool = new ComputeBufferPool(); DynamicArray m_RendererListResources = new DynamicArray(); RenderGraphDebugParams m_RenderGraphDebug; @@ -180,9 +181,10 @@ ResType GetResource(DynamicArray resour return res.resource; } - internal void BeginRender(int currentFrameIndex) + internal void BeginRender(int currentFrameIndex, int executionCount) { m_CurrentFrameIndex = currentFrameIndex; + ResourceHandle.NewFrame(executionCount); current = this; } @@ -242,7 +244,7 @@ internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt) if (m_CurrentBackbuffer != null) m_CurrentBackbuffer.SetTexture(rt); else - m_CurrentBackbuffer = RTHandles.Alloc(rt); + m_CurrentBackbuffer = RTHandles.Alloc(rt, "Backbuffer"); int newHandle = AddNewResource(m_Resources[(int)RenderGraphResourceType.Texture], out TextureResource texResource); texResource.resource = m_CurrentBackbuffer; @@ -349,7 +351,7 @@ internal void CreateAndClearTexture(RenderGraphContext rgContext, int index) { // Textures are going to be reused under different aliases along the frame so we can't provide a specific name upon creation. // The name in the desc is going to be used for debugging purpose and render graph visualization. - string name = "RenderGraphTexture"; + string name = $"RenderGraphTexture_{m_TextureCreationIndex++}"; switch (desc.sizeMode) { @@ -574,6 +576,8 @@ internal void Cleanup() { m_TexturePool.Cleanup(); m_ComputeBufferPool.Cleanup(); + + RTHandles.Release(m_CurrentBackbuffer); } void LogTextureCreation(TextureResource rt) @@ -615,6 +619,7 @@ void LogResources() m_Logger.LogLine("==== Allocated Resources ====\n"); m_TexturePool.LogResources(m_Logger); + m_Logger.LogLine(""); m_ComputeBufferPool.LogResources(m_Logger); } } diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs index c3823aa650b..1d80f13da62 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs @@ -11,34 +11,50 @@ internal enum RenderGraphResourceType Count } - // Can't have a default constructor with handle = -1 hence the ugly IsValid implementation (where m_IsValid will be false by default). internal struct ResourceHandle { - bool m_IsValid; + // Note on handles validity. + // PassData classes used during render graph passes are pooled and because of that, when users don't fill them completely, + // they can contain stale handles from a previous render graph execution that could still be considered valid if we only checked the index. + // In order to avoid using those, we incorporate the execution index in a 16 bits hash to make sure the handle is coming from the current execution. + // If not, it's considered invalid. + // We store this validity mask in the upper 16 bits of the index. + const uint kValidityMask = 0xFFFF0000; + const uint kIndexMask = 0xFFFF; - public int index { get; private set; } + uint m_Value; + + static uint s_CurrentValidBit = 1 << 16; + + public int index { get { return (int)(m_Value & kIndexMask); } } public RenderGraphResourceType type { get; private set; } public int iType { get { return (int)type; } } internal ResourceHandle(int value, RenderGraphResourceType type) { - index = value; + Debug.Assert(value <= 0xFFFF); + m_Value = ((uint)value & kIndexMask) | s_CurrentValidBit; this.type = type; - m_IsValid = true; } public static implicit operator int(ResourceHandle handle) => handle.index; - public bool IsValid() => m_IsValid; - } + public bool IsValid() + { + var validity = m_Value & kValidityMask; + return validity != 0 && validity == s_CurrentValidBit; + } - // BEHOLD C# COPY PASTA - // Struct can't be inherited and can't have default member values or constructor - // Hence the copy paste and the ugly IsValid implementation. + static public void NewFrame(int executionIndex) + { + // Scramble frame count to avoid collision when wrapping around. + s_CurrentValidBit = (uint)(((executionIndex >> 16) ^ (executionIndex & 0xffff) * 58546883) << 16); + } + } /// /// Texture resource handle. /// - [DebuggerDisplay("Texture ({handle})")] + [DebuggerDisplay("Texture ({handle.index})")] public struct TextureHandle { private static TextureHandle s_NullHandle = new TextureHandle(); @@ -84,7 +100,7 @@ public struct TextureHandle /// /// Compute Buffer resource handle. /// - [DebuggerDisplay("ComputeBuffer ({handle})")] + [DebuggerDisplay("ComputeBuffer ({handle.index})")] public struct ComputeBufferHandle { private static ComputeBufferHandle s_NullHandle = new ComputeBufferHandle(); diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs index 66619d946c4..91b0c5a02bc 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs @@ -825,6 +825,17 @@ public RTHandle Alloc(Texture texture) /// Input render target identifier. /// A new RTHandle referencing the input render target identifier. public RTHandle Alloc(RenderTargetIdentifier texture) + { + return Alloc(texture, ""); + } + + /// + /// Allocate a RTHandle from a regular render target identifier. + /// + /// Input render target identifier. + /// Name of the texture. + /// A new RTHandle referencing the input render target identifier. + public RTHandle Alloc(RenderTargetIdentifier texture, string name) { var rth = new RTHandle(this); rth.SetTexture(texture); @@ -832,7 +843,7 @@ public RTHandle Alloc(RenderTargetIdentifier texture) rth.m_EnableRandomWrite = false; rth.useScaling = false; rth.m_EnableHWDynamicScale = false; - rth.m_Name = ""; + rth.m_Name = name; return rth; } diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs index e9d669e3aed..342ce9c58a8 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs @@ -250,6 +250,17 @@ public static RTHandle Alloc(RenderTargetIdentifier tex) return s_DefaultInstance.Alloc(tex); } + /// + /// Allocate a RTHandle from a regular render target identifier for the default RTHandle system. + /// + /// Input render target identifier. + /// Name of the render target. + /// A new RTHandle referencing the input render target identifier. + public static RTHandle Alloc(RenderTargetIdentifier tex, string name) + { + return s_DefaultInstance.Alloc(tex, name); + } + private static RTHandle Alloc(RTHandle tex) { Debug.LogError("Allocation a RTHandle from another one is forbidden."); diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl index c318581e16b..3981ef50a88 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl @@ -46,6 +46,7 @@ #define HALF_MIN_SQRT 0.0078125 // 2^-7 == sqrt(HALF_MIN), useful for ensuring HALF_MIN after x^2 #define HALF_MAX 65504.0 #define UINT_MAX 0xFFFFFFFFu +#define INT_MAX 0x7FFFFFFF #ifdef SHADER_API_GLES diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index a34f17983a9..4845040bccd 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -29,6 +29,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added the export of normals during the prepass for shadow matte for proper SSAO calculation. - Added the usage of SSAO for shadow matte unlit shader graph. - Added the support of input system V2 +- Added a new volume component parameter to control the max ray length of directional lights(case 1279849). +- Added support for 'Pyramid' and 'Box' spot light shapes in path tracing. +- Added high quality prefiltering option for Bloom. ### Fixed - Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc) @@ -100,6 +103,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed alignment of framesettings in HDRP Default Settings - Fixed an exception thrown when closing the look dev because there is no active SRP anymore. - Fixed an issue where entering playmode would close the LookDev window. +- Fixed issue with rendergraph on console failing on SSS pass. - Fixed Cutoff not working properly with ray tracing shaders default and SG (case 1261292). - Fixed shader compilation issue with Hair shader and debug display mode - Fixed cubemap static preview not updated when the asset is imported. @@ -116,6 +120,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an error when building the player. - Fixed issue with box light not visible if range is below one and range attenuation is off. - Fixed an issue that caused a null reference when deleting camera component in a prefab. (case 1244430) +- Fixed issue with bloom showing a thin black line after rescaling window. +- Fixed rendergraph motion vector resolve. +- Fixed the Ray-Tracing related Debug Display not working in render graph mode. +- Fix nan in pbr sky +- Fixed Light skin not properly applied on the LookDev when switching from Dark Skin (case 1278802) +- Fixed accumulation on DX11 +- Fixed issue with screen space UI not drawing on the graphics compositor (case 1279272). +- Fixed error Maximum allowed thread group count is 65535 when resolution is very high. +- LOD meshes are now properly stripped based on the maximum lod value parameters contained in the HDRP asset. +- Fixed an inconsistency in the LOD group UI where LOD bias was not the right one. +- Fixed outlines in transitions between post-processed and plain regions in the graphics compositor (case 1278775). +- Fix decal being applied twice with LOD Crossfade. +- Fixed camera stacking for AOVs in the graphics compositor (case 1273223). ### Changed - Preparation pass for RTSSShadows to be supported by render graph. @@ -144,6 +161,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - On platforms that allow it skip the first mip of the depth pyramid and compute it alongside the depth buffer used for low res transparents. - When trying to install the local configuration package, if another one is already present the user is now asked whether they want to keep it or not. - Improved MSAA color resolve to fix issues when very bright and very dark samples are resolved together. +- Improve performance of GPU light AABB generation +- Removed the max clamp value for the RTR, RTAO and RTGI's ray length (case 1279849). +- Meshes assigned with a decal material are not visible anymore in ray-tracing or path-tracing. ## [10.0.0] - 2019-06-10 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Accumulation.md b/com.unity.render-pipelines.high-definition/Documentation~/Accumulation.md index b0c50801f05..953427d9968 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Accumulation.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Accumulation.md @@ -69,7 +69,7 @@ public class FrameManager : MonoBehaviour { RenderPipelineManager.beginFrameRendering -= PrepareSubFrameCallBack; HDRenderPipeline renderPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline; - renderPipeline.EndRecording(); + renderPipeline?.EndRecording(); m_Recording = false; } diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md index 0662ad53939..d01f5467374 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Feature-Comparison.md @@ -210,6 +210,13 @@ The tables that follow provide an overview of the **Features** that the High Def | Hair | Not supported | Yes | | Fabric | Not supported | Yes | +## LOD Management +In the Built-in Render Pipeline, you manage levels of detail (LOD) from the QualitySettings. Each quality setting defines a LOD Bias and a Maximum LOD value. As such, they are global to the quality setting and you cannot change them on a per camera basis. In HDRP, there are scalability settings that allow you to change the LOD settings per camera by using either predetermined values contained in the HDRP Asset of the current quality level or overridden values. For more information, see [HDRP Asset](HDRP-Asset.md) and [Frame Settings](Frame-Settings.md). + +Managing LOD in this way has two consequences: +- Default LOD settings for a quality level are now stored in the HDRP Asset instead of the Quality Settings. +- Built-in APIs such as QualitySettings.lodBias or QualitySettings.maximumLODLevel no longer work. Instead, you need to change these properties through the camera Frame Settings. If you use the Built-in APIs, they have no effect at all. + ## Render Pipeline Hooks | **Feature** | **Built-in Render Pipeline** | **High Definition Render Pipeline (HDRP)** | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md index 89ed5c4dc0e..ee210a1d055 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Master-Node-Decal.md @@ -55,8 +55,9 @@ To view these properties, click the gear in the top right of the Master Node. | **Affects Ambient Occlusion** | Enable or disable the effect of the **Ambient Occlusion** property. | | **Affects Smoothness** | Enable or disable the effect of the **Smoothness** property. | | **Affects Emission** | Enable or disable the effect of the **Emission** property. | +| **Support LOD CrossFace** | Indicates whether dithering occurs when moving from one LOD level of the receiving Mesh to another when sampling Textures. Only use with Decal Mesh. | | **Override ShaderGUI** | Lets you override the [ShaderGUI](https://docs.unity3d.com/ScriptReference/ShaderGUI.html) that this Shader Graph uses. If `true`, the **ShaderGUI** property appears, which lets you specify the ShaderGUI to use. | -| **- ShaderGUI** | The full name of the ShaderGUI class to use, including the class path. | +| **- ShaderGUI** | The full name of the ShaderGUI class to use, including the class path. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Bloom.md b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Bloom.md index a657aefba35..5ae768df948 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Bloom.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Post-Processing-Bloom.md @@ -40,6 +40,7 @@ Bloom includes [more options](More-Options.md) that you must manually expose. | **Property** | **Description** | | -------------------------- | ------------------------------------------------------------ | | **Resolution** | Use the drop-down to set the resolution at which HDRP processes the Bloom effect. If you target consoles that use a very high resolution (for example, 4k), select **Quarter,** because it is less resource-intensive.
• **Quarter**: Uses quarter the screen resolution.
• **Half**: Uses half the screen resolution. This property only appears when you enable [more options](More-Options.md). | +| **High Quality Prefiltering** | Enable the checkbox to make HDRP use 13 samples instead of 4 during the prefiltering pass. This increases the resource intensity of the Bloom effect, but results in less flickering by small and bright objects like the sun.
This property only appears when you enable [more options](More-Options.md). | | **High Quality Filtering** | Enable the checkbox to make HDRP use bicubic filtering instead of bilinear filtering. This increases the resource intensity of the Bloom effect, but results in smoother visuals.
This property only appears when you enable [more options](More-Options.md). | | **Anamorphic** | Enable the checkbox to make the bloom effect take the **Anamorphism** property of the Camera into account. This stretches the bloom horizontally or vertically like it would on anamorphic sensors.
This property only appears when you enable [more options](More-Options.md). | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md index 105afe19a9f..45c4ac3958f 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md @@ -62,7 +62,7 @@ Ray-Traced Ambient Occlusion uses the [Volume](Volumes.md) framework, so to enab | **Direct Lighting Strength** | Controls how much the ambient occlusion affects direct lighting. | | **LayerMask** | Defines the layers that HDRP processes this ray-traced effect for. | | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually. | -| - **Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. This allows you to have smaller scale, local, ambient occlusion. | +| - **Max Ray Length** | Controls the maximal ray length of the rays that HDRP uses for ray traced ambient occlusion. This allows you to have smaller scale, local, ambient occlusion. | | - **Sample Count** | Controls the number of rays that HDRP uses per pixel, per frame. Increasing this value increases execution time linearly. | | - **Denoise** | Enables the spatio-temporal filter that HDRP uses to remove noise from the ambient occlusion. | | - - **Denoiser Radius** | Controls the radius of the spatio-temporal filter. A higher value reduces noise further. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md index 5ad3e4dad4a..9ad0873edb9 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md @@ -49,7 +49,7 @@ Alongside the standard properties, Unity makes different properties available de | **LayerMask** | Defines the layers that HDRP processes this ray-traced effect for. | | **Mode** | Defines if HDRP should evaluate the effect in **Performance** or **Quality** mode.
This property only appears if you select set **Supported Ray Tracing Mode** in your HDRP Asset to **Both**. | | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually.
This property only appears in [Performance](Ray-Tracing-Getting-Started.md#ray-tracing-mode) mode. | -| **Ray Length** | Set a value to control the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky. | +| **Max Ray Length** | Controls the maximal length of reflection rays. The higher this value is, the more expensive ray traced reflections are. If a ray doesn't find an intersection, then the ray returns the color of the sky if Reflect Sky is enabled, or black if not. | | **Clamp Value** | Set a value to control the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the global illumination more stable to denoise, but reduces quality. | | **Denoise** | Enable this to enable the spatio-temporal filter that HDRP uses to remove noise from the Ray-Traced Global Illumination. | | - **Half Resolution Denoiser** | Enable this feature to evaluate the spatio-temporal filter in half resolution. This decreases the resource intensity of denoising but reduces quality. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md index 089e91e5a81..9725cbc7d21 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md @@ -66,7 +66,7 @@ Alongside the standard properties, Unity exposes extra properties depending on t | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually.
This property only appears in [Performance](Ray-Tracing-Getting-Started.md#ray-tracing-mode) mode. | | **Minimum Smoothness** | Controls the minimum smoothness value for a pixel at which HDRP processes ray-traced reflections. If the smoothness value of the pixel is lower than this value, HDRP falls back to the next available reflection method in the [reflection hierarchy](Reflection-in-HDRP.md#ReflectionHierarchy). | | **Smoothness Fade Start** | Controls the smoothness value at which the smoothness controlled fade out starts. The fade is in the range [Minimum Smoothness, Smoothness Fade Start]. | -| **Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky if Reflect Sky is enabled, or black if not. | +| **Max Ray Length** | Controls the maximal length of global illumination rays. The higher this value is, the more expensive ray traced global illumination is. If a ray doesn't find an intersection. | | **Clamp Value** | Controls the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the reflections more stable to denoise, but reduces quality. | | **Denoise** | Enables the spatio-temporal filter that HDRP uses to remove noise from the reflections. | | - **Denoiser Radius** | Controls the radius of the spatio-temporal filter. Increasing this value results in a more blurry result and a higher execution time. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md index f0007113233..32bab15a3c8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md @@ -14,3 +14,4 @@ In the High Definition Render Pipeline (HDRP), various ray-traced effects share | **Ray Bias** | Specifies the bias value HDRP applies when casting rays for all effects. This value should remain unchained unless your scene scale is significantly smaller or larger than average. | | **Extend Shadow Culling** | Extends the sets of GameObjects that HDRP includes in shadow maps for more accurate shadows in ray traced effects. | | **Extend Camera Culling** | Extends the sets of GameObjects that HDRP includes in the rendering. This is a way to force skinned mesh animations for GameObjects that are not in the frustum. | +| **Directional Shadow Ray Length** | Controls the maximal ray length for ray traced directional shadows. | \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs index 743e237397d..4282db7752d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs +++ b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessBuild.cs @@ -10,6 +10,23 @@ class HDRPPreprocessBuild : IPreprocessBuildWithReport { public int callbackOrder { get { return 0; } } + int GetMinimumMaxLoDValue(HDRenderPipelineAsset asset) + { + int minimumMaxLoD = int.MaxValue; + var maxLoDs = asset.currentPlatformRenderPipelineSettings.maximumLODLevel; + var schema = ScalableSettingSchema.GetSchemaOrNull(maxLoDs.schemaId); + for (int lod = 0; lod < schema.levelCount; ++lod) + { + if (maxLoDs.TryGet(lod, out int maxLoD)) + minimumMaxLoD = Mathf.Min(minimumMaxLoD, maxLoD); + } + + if (minimumMaxLoD != int.MaxValue) + return minimumMaxLoD; + else + return 0; + } + public void OnPreprocessBuild(BuildReport report) { // Detect if the users forget to assign an HDRP Asset @@ -38,16 +55,35 @@ public void OnPreprocessBuild(BuildReport report) // If platform is supported all good GraphicsDeviceType unsupportedGraphicDevice = GraphicsDeviceType.Null; - if (HDUtils.AreGraphicsAPIsSupported(report.summary.platform, out unsupportedGraphicDevice) + bool supported = HDUtils.AreGraphicsAPIsSupported(report.summary.platform, out unsupportedGraphicDevice) && HDUtils.IsSupportedBuildTarget(report.summary.platform) - && HDUtils.IsOperatingSystemSupported(SystemInfo.operatingSystem)) - return; + && HDUtils.IsOperatingSystemSupported(SystemInfo.operatingSystem); - unsupportedGraphicDevice = (unsupportedGraphicDevice == GraphicsDeviceType.Null) ? SystemInfo.graphicsDeviceType : unsupportedGraphicDevice; - string msg = "The platform " + report.summary.platform.ToString() + " with the graphic API " + unsupportedGraphicDevice + " is not supported with High Definition Render Pipeline"; + if (!supported) + { + unsupportedGraphicDevice = (unsupportedGraphicDevice == GraphicsDeviceType.Null) ? SystemInfo.graphicsDeviceType : unsupportedGraphicDevice; + string msg = "The platform " + report.summary.platform.ToString() + " with the graphic API " + unsupportedGraphicDevice + " is not supported with High Definition Render Pipeline"; - // Throw an exception to stop the build - throw new BuildFailedException(msg); + // Throw an exception to stop the build + throw new BuildFailedException(msg); + } + + // Update all quality levels with the right max lod so that meshes can be stripped. + // We don't take lod bias into account because it can be overridden per camera. + int qualityLevelCount = QualitySettings.names.Length; + for (int i = 0; i < qualityLevelCount; ++i) + { + QualitySettings.SetQualityLevel(i, false); + var renderPipeline = QualitySettings.renderPipeline as HDRenderPipelineAsset; + if (renderPipeline != null) + { + QualitySettings.maximumLODLevel = GetMinimumMaxLoDValue(renderPipeline); + } + else + { + QualitySettings.maximumLODLevel = GetMinimumMaxLoDValue(hdPipelineAsset); + } + } } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositionLayerUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositionLayerUI.Drawers.cs index 6fe41ad78aa..e5796f44981 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositionLayerUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositionLayerUI.Drawers.cs @@ -30,6 +30,7 @@ static partial class Styles static public readonly GUIContent k_AAMode = EditorGUIUtility.TrTextContent("Post Anti-aliasing", "To override the postprocess Anti-aliasing mode, activate the option by clicking on the check-box and then select the desired value."); static public readonly GUIContent k_CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "To override the culling mask, activate the option by clicking on the check-box and then select the desired value."); static public readonly GUIContent k_VolumeMask = EditorGUIUtility.TrTextContent("Volume Mask", "To override the volume mask, activate the option by clicking on the check-box and then select the desired value."); + static public readonly GUIContent k_AlphaRange = EditorGUIUtility.TrTextContent("Alpha Range", "The range of alpha values used when transitioning from post-processed to plain image regions. A smaller range will result in a steeper transition."); static public readonly string k_AlphaInfoPost = "The use of AOVs properties in a player require to to enable the Runtime AOV API support in the HDRP quality settings."; @@ -178,6 +179,58 @@ public static void DrawStackedLayerProperties(Rect rect, SerializedCompositionLa rect.y += CompositorStyle.k_Spacing; EditorGUI.PropertyField(rect, serializedProperties.clearAlpha, Styles.k_ClearAlpha); + rect.y += 1.0f * CompositorStyle.k_Spacing; + + // Draw a min/max slider for tha alpha range + { + const float spacing = 5; + var labelRect = new Rect(rect.x, rect.y, EditorGUIUtility.labelWidth, rect.height); + EditorGUI.PrefixLabel(labelRect, Styles.k_AlphaRange); + + var minLabelRect = rect; + minLabelRect.x += EditorGUIUtility.labelWidth; + minLabelRect.width = EditorGUIUtility.fieldWidth / 2; + serializedProperties.alphaMin.floatValue = EditorGUI.FloatField(minLabelRect, serializedProperties.alphaMin.floatValue); + + GUI.SetNextControlName("AlphaMinMaxSlider"); + var sliderRect = rect; + sliderRect.x += EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth / 2 + spacing; + sliderRect.width -= (EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth + 2 * spacing); + float minVal = serializedProperties.alphaMin.floatValue; + float maxVal = serializedProperties.alphaMax.floatValue; + + EditorGUI.MinMaxSlider(sliderRect, ref minVal, ref maxVal, 0, 1); + if (serializedProperties.alphaMin.floatValue != minVal || serializedProperties.alphaMax.floatValue != maxVal) + { + // Note: We need to move the focus when the slider changes, otherwise the textField will not update + GUI.FocusControl("AlphaMinMaxSlider"); + serializedProperties.alphaMin.floatValue = minVal; + serializedProperties.alphaMax.floatValue = maxVal; + } + + var maxLabelRect = rect; + maxLabelRect.x = sliderRect.x + sliderRect.width + spacing; + maxLabelRect.width = EditorGUIUtility.fieldWidth / 2; + serializedProperties.alphaMax.floatValue = EditorGUI.FloatField(maxLabelRect, serializedProperties.alphaMax.floatValue); + + // sanity checks + if (serializedProperties.alphaMax.floatValue < serializedProperties.alphaMin.floatValue) + { + serializedProperties.alphaMax.floatValue = serializedProperties.alphaMin.floatValue; + } + if (serializedProperties.alphaMax.floatValue > 1) + { + serializedProperties.alphaMax.floatValue = 1; + } + if (serializedProperties.alphaMin.floatValue > serializedProperties.alphaMax.floatValue) + { + serializedProperties.alphaMin.floatValue = serializedProperties.alphaMax.floatValue; + } + if (serializedProperties.alphaMin.floatValue < 0) + { + serializedProperties.alphaMin.floatValue = 0; + } + } rect.y += 1.5f * CompositorStyle.k_Spacing; // The clear mode should be visible / configurable only for the first layer in the stack. For the other layers we set a camera-stacking specific clear-mode . diff --git a/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs b/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs index b3611d288fd..95215eeaad0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Compositor/CompositorWindow.cs @@ -190,12 +190,17 @@ private void OnDestroy() GraphData.onSaveGraph -= MarkShaderAsDirty; Undo.undoRedoPerformed -= UndoCallback; - s_SelectionIndex = m_Editor.selectionIndex; + s_SelectionIndex = m_Editor ? m_Editor.selectionIndex : -1; } void UndoCallback() { // Undo-redo might change the layer order, so we need to redraw the compositor UI and also refresh the layer setup + if (!m_Editor) + { + return; + } + m_Editor.CacheSerializedObjects(); m_RequiresRedraw = true; s_SelectionIndex = m_Editor.selectionIndex; diff --git a/com.unity.render-pipelines.high-definition/Editor/Compositor/SerializedCompositionLayer.cs b/com.unity.render-pipelines.high-definition/Editor/Compositor/SerializedCompositionLayer.cs index 9a88b20f6dd..1f08919219f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Compositor/SerializedCompositionLayer.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Compositor/SerializedCompositionLayer.cs @@ -30,6 +30,8 @@ internal class SerializedCompositionLayer public SerializedProperty aovBitmask; public SerializedProperty inputFilters; public SerializedProperty positionInStack; + public SerializedProperty alphaMin; + public SerializedProperty alphaMax; public List filterList = new List(); @@ -60,6 +62,8 @@ public SerializedCompositionLayer(SerializedProperty root) aovBitmask = root.FindPropertyRelative("m_AOVBitmask"); inputFilters = root.FindPropertyRelative("m_InputFilters"); positionInStack = root.FindPropertyRelative("m_LayerPositionInStack"); + alphaMin = root.FindPropertyRelative("m_AlphaMin"); + alphaMax = root.FindPropertyRelative("m_AlphaMax"); for (int index = 0; index < inputFilters.arraySize; index++) { @@ -91,7 +95,8 @@ public float GetPropertiesHeight() EditorGUI.GetPropertyHeight(cullingMaskProperty, null) + EditorGUI.GetPropertyHeight(volumeMask, null) + EditorGUI.GetPropertyHeight(inputFilters, null) + - EditorGUIUtility.singleLineHeight * 7; //for the heading and pading + EditorGUI.GetPropertyHeight(alphaMin, null) + // we use a min/max slider in the UI so it takes a sinle line, so we don't need to count the alphaMax + EditorGUIUtility.singleLineHeight * 7; // for the heading and pading if (inputFilters.arraySize > 0) { diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs index 81e0f679b79..dbfb814846f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs @@ -87,7 +87,7 @@ public override void OnInspectorGUI() using (new EditorGUI.DisabledScope(!useCustomValue)) { EditorGUI.indentLevel++; - PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Ray Length", "Controls the length of ambient occlusion rays.")); + PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of ambient occlusion rays. The higher this value is, the more expensive ray traced ambient occlusion is.")); PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for ray traced ambient occlusion.")); PropertyField(m_Denoise, EditorGUIUtility.TrTextContent("Denoise", "Enable denoising on the ray traced ambient occlusion.")); { diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs index d5364b9a6d8..fa449727f64 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs @@ -80,7 +80,7 @@ public override void OnEnable() static public readonly GUIContent k_ScreenFaceDistanceText = EditorGUIUtility.TrTextContent("Screen Edge Fade Distance", "Controls the distance at which HDRP fades out SSR near the edge of the screen."); static public readonly GUIContent k_DepthBufferThicknessText = EditorGUIUtility.TrTextContent("Object Thickness", "Controls the typical thickness of objects the reflection rays may pass behind."); static public readonly GUIContent k_RayMaxIterationsText = EditorGUIUtility.TrTextContent("Max Ray Steps", "Sets the maximum number of steps HDRP uses for raytracing. Affects both correctness and performance."); - static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Ray Length", "Controls the length of reflection rays."); + static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of reflection rays. The higher this value is, the more expensive ray traced reflections are."); static public readonly GUIContent k_ClampValueText = EditorGUIUtility.TrTextContent("Clamp Value", "Clamps the exposed intensity."); static public readonly GUIContent k_SampleCountText = EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for reflections."); static public readonly GUIContent k_BounceCountText = EditorGUIUtility.TrTextContent("Bounce Count", "Number of bounces for reflection rays."); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalData.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalData.cs index 1e68dcbfcfc..1dbc32acb52 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalData.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalData.cs @@ -62,6 +62,14 @@ public int drawOrder set => m_DrawOrder = value; } + [SerializeField] + bool m_SupportLodCrossFade; + public bool supportLodCrossFade + { + get => m_SupportLodCrossFade; + set => m_SupportLodCrossFade = value; + } + public bool affectsMaskmap => affectsSmoothness || affectsMetal || affectsAO; } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPass.template index 0804a8cd692..75f9485c2e1 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPass.template +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPass.template @@ -97,6 +97,10 @@ Pass fragInputs.tangentToWorld[2].xyz = TransformObjectToWorldDir(float3(0, 1, 0)); fragInputs.tangentToWorld[1].xyz = TransformObjectToWorldDir(float3(0, 0, 1)); #else + #ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group + LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x); + #endif + float fadeFactor = 1.0; #endif diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPropertyBlock.cs index 25d5b64f758..8ac81ea3154 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalPropertyBlock.cs @@ -29,6 +29,7 @@ protected override void CreatePropertyGUI() AddProperty(affectAmbientOcclusionText, () => decalData.affectsAO, (newValue) => decalData.affectsAO = newValue); AddProperty(affectSmoothnessText, () => decalData.affectsSmoothness, (newValue) => decalData.affectsSmoothness = newValue); AddProperty(affectEmissionText, () => decalData.affectsEmission, (newValue) => decalData.affectsEmission = newValue); + AddProperty(supportLodCrossFadeText, () => decalData.supportLodCrossFade, (newValue) => decalData.supportLodCrossFade = newValue); } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs index f1a52a975ba..b8c619b31f6 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs @@ -70,6 +70,12 @@ protected override void CollectPassKeywords(ref PassDescriptor pass) if (decalData.affectsMaskmap) pass.keywords.Add(DecalDefines.Maskmap); } + + if (pass.lightMode == DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DecalMeshForwardEmissive] || + pass.lightMode == DecalSystem.s_MaterialDecalPassNames[(int)DecalSystem.MaterialDecalPass.DBufferMesh]) + { + pass.keywords.Add(CoreKeywordDescriptors.LodFadeCrossfade, new FieldCondition(Fields.LodCrossFade, true)); + } } public static FieldDescriptor AffectsAlbedo = new FieldDescriptor(kMaterial, "AffectsAlbedo", ""); @@ -93,6 +99,7 @@ public override void GetFields(ref TargetFieldContext context) context.AddField(AffectsMaskMap, decalData.affectsMaskmap); context.AddField(DecalDefault, decalData.affectsAlbedo || decalData.affectsNormal || decalData.affectsMetal || decalData.affectsAO || decalData.affectsSmoothness ); + context.AddField(Fields.LodCrossFade, decalData.supportLodCrossFade); } public override void GetActiveBlocks(ref TargetActiveBlockContext context) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceOptionsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceOptionsUIBlock.cs index 03c33a12fce..86aca5c42ce 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceOptionsUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSurfaceOptionsUIBlock.cs @@ -22,6 +22,7 @@ public class Styles public static GUIContent affectAmbientOcclusionText = new GUIContent("Affect Ambient Occlusion", "When enabled, this decal uses the smoothness channel of its Mask Map. When disabled, the decal has no smoothness effect."); public static GUIContent affectSmoothnessText = new GUIContent("Affect Smoothness", "When enabled, this decal uses the ambient occlusion channel of its Mask Map. When disabled, the decal has no ambient occlusion effect."); public static GUIContent affectEmissionText = new GUIContent("Affect Emission", "When enabled, this decal becomes emissive and appears self-illuminated. Affect Emission does not support Affects Transparents option on Decal Projector."); + public static GUIContent supportLodCrossFadeText = new GUIContent("Support LOD CrossFade", "When enabled, this decal material supports LOD Cross fade if use on a Mesh."); } Expandable m_ExpandableBit; diff --git a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs index 00a3e786e2b..12ff10becad 100644 --- a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/BloomEditor.cs @@ -15,6 +15,7 @@ sealed class BloomEditor : VolumeComponentWithQualityEditor SerializedDataParameter m_DirtIntensity; // Advanced settings + SerializedDataParameter m_HighQualityPrefiltering; SerializedDataParameter m_HighQualityFiltering; SerializedDataParameter m_Resolution; SerializedDataParameter m_Anamorphic; @@ -34,6 +35,7 @@ public override void OnEnable() m_DirtTexture = Unpack(o.Find(x => x.dirtTexture)); m_DirtIntensity = Unpack(o.Find(x => x.dirtIntensity)); + m_HighQualityPrefiltering = Unpack(o.Find("m_HighQualityPrefiltering")); m_HighQualityFiltering = Unpack(o.Find("m_HighQualityFiltering")); m_Resolution = Unpack(o.Find("m_Resolution")); m_Anamorphic = Unpack(o.Find(x => x.anamorphic)); @@ -59,6 +61,7 @@ public override void OnInspectorGUI() using (new EditorGUI.DisabledScope(!useCustomValue)) { PropertyField(m_Resolution); + PropertyField(m_HighQualityPrefiltering); PropertyField(m_HighQualityFiltering); } PropertyField(m_Anamorphic); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index aec24785382..620fe31e277 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -57,6 +57,7 @@ public class GeneralSection public static readonly GUIContent maxRadiusQuality = EditorGUIUtility.TrTextContent("Max Radius"); public static readonly GUIContent sampleCountQuality = EditorGUIUtility.TrTextContent("Sample Count"); public static readonly GUIContent resolutionQuality = EditorGUIUtility.TrTextContent("Resolution"); + public static readonly GUIContent highQualityPrefiltering = EditorGUIUtility.TrTextContent("High Quality Filtering"); public static readonly GUIContent highQualityFiltering = EditorGUIUtility.TrTextContent("High Quality Filtering"); public static readonly GUIContent dofPhysicallyBased = EditorGUIUtility.TrTextContent("Physically Based"); public static readonly GUIContent maxSamplesQuality = EditorGUIUtility.TrTextContent("Max Samples"); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index 7a3349d9d93..7eea5b34d19 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -673,6 +673,7 @@ static void Drawer_SectionMotionBlurQualitySettings(SerializedHDRenderPipelineAs static void DrawBloomQualitySetting(SerializedHDRenderPipelineAsset serialized, int tier) { EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.BloomRes.GetArrayElementAtIndex(tier), Styles.resolutionQuality); + EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.BloomHighPrefilteringQuality.GetArrayElementAtIndex(tier), Styles.highQualityPrefiltering); EditorGUILayout.PropertyField(serialized.renderPipelineSettings.postProcessQualitySettings.BloomHighFilteringQuality.GetArrayElementAtIndex(tier), Styles.highQualityFiltering); } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs index 2ec5e495cba..2c7cb031ecd 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs @@ -75,6 +75,7 @@ public override void OnEnable() m_SecondDenoiserPass = Unpack(o.Find(x => x.secondDenoiserPass)); } + static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of global illumination rays. The higher this value is, the more expensive ray traced global illumination is."); static public readonly GUIContent k_DepthBufferThicknessText = EditorGUIUtility.TrTextContent("Object Thickness", "Controls the typical thickness of objects the global illumination rays may pass behind."); public void DenoiserGUI() @@ -130,6 +131,7 @@ public override void OnInspectorGUI() EditorGUI.indentLevel++; using (new EditorGUI.DisabledScope(!useCustomValue)) { + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_RayLength); PropertyField(m_ClampValue); PropertyField(m_FullResolution); @@ -142,7 +144,7 @@ public override void OnInspectorGUI() break; case RayTracingMode.Quality: { - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_SampleCount); PropertyField(m_BounceCount); @@ -154,7 +156,7 @@ public override void OnInspectorGUI() } else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality) { - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_SampleCount); PropertyField(m_BounceCount); @@ -166,6 +168,7 @@ public override void OnInspectorGUI() EditorGUI.indentLevel++; using (new EditorGUI.DisabledScope(!useCustomValue)) { + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_RayLength); PropertyField(m_ClampValue); PropertyField(m_FullResolution); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs index e115aaa952a..23a8b7eb84a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs @@ -11,6 +11,7 @@ class RayTracingSettingsEditor : VolumeComponentEditor SerializedDataParameter m_RayBias; SerializedDataParameter m_ExtendShadowCulling; SerializedDataParameter m_ExtendCameraCulling; + SerializedDataParameter m_DirectionalShadowRayLength; public override void OnEnable() { @@ -21,6 +22,7 @@ public override void OnEnable() m_RayBias = Unpack(o.Find(x => x.rayBias)); m_ExtendShadowCulling = Unpack(o.Find(x => x.extendShadowCulling)); m_ExtendCameraCulling = Unpack(o.Find(x => x.extendCameraCulling)); + m_DirectionalShadowRayLength = Unpack(o.Find(x => x.directionalShadowRayLength)); } public override void OnInspectorGUI() @@ -36,6 +38,7 @@ public override void OnInspectorGUI() PropertyField(m_RayBias); PropertyField(m_ExtendShadowCulling); PropertyField(m_ExtendCameraCulling); + PropertyField(m_DirectionalShadowRayLength); } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs index c6ce192174c..1800666e722 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedPostProcessingQualitySettings.cs @@ -22,6 +22,7 @@ class SerializedPostProcessingQualitySettings // Bloom public SerializedProperty BloomRes; public SerializedProperty BloomHighFilteringQuality; + public SerializedProperty BloomHighPrefilteringQuality; // Chromatic Aberration public SerializedProperty ChromaticAbMaxSamples; @@ -45,6 +46,7 @@ public SerializedPostProcessingQualitySettings(SerializedProperty root) // Bloom BloomRes = root.Find((GlobalPostProcessingQualitySettings s) => s.BloomRes); BloomHighFilteringQuality = root.Find((GlobalPostProcessingQualitySettings s) => s.BloomHighQualityFiltering); + BloomHighPrefilteringQuality= root.Find((GlobalPostProcessingQualitySettings s) => s.BloomHighQualityPrefiltering); // Chromatic Aberration ChromaticAbMaxSamples = root.Find((GlobalPostProcessingQualitySettings s) => s.ChromaticAberrationMaxSamples); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/AdditionalCompositorData.cs b/com.unity.render-pipelines.high-definition/Runtime/Compositor/AdditionalCompositorData.cs index 972c946cb10..cfc3a55dd23 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/AdditionalCompositorData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/AdditionalCompositorData.cs @@ -14,9 +14,12 @@ internal enum BackgroundFitMode internal class AdditionalCompositorData : MonoBehaviour { public Texture clearColorTexture = null; + public RenderTexture clearDepthTexture = null; public bool clearAlpha = true; // Clearing the alpha allows the post process to run only on the pixels covered by a stacked camera (and not the previous ones). public BackgroundFitMode imageFitMode = BackgroundFitMode.Stretch; public List layerFilters; + public float alphaMax = 1.0f; + public float alphaMin = 0.0f; public void Init(List layerFilters, bool clearAlpha) { @@ -27,6 +30,7 @@ public void Init(List layerFilters, bool clearAlpha) public void ResetData() { clearColorTexture = null; + clearDepthTexture = null; clearAlpha = true; imageFitMode = BackgroundFitMode.Stretch; @@ -36,6 +40,8 @@ public void ResetData() layerFilters = null; } + alphaMax = 1.0f; + alphaMin = 0.0f; } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionLayer.cs b/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionLayer.cs index 1295258a3e7..2ca6e1ffad2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionLayer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionLayer.cs @@ -54,6 +54,8 @@ public enum ResolutionScale [SerializeField] bool m_ClearAlpha = true; // Specifies if the Alpha channel will be cleared when stacking this camera over the previous one (for overlays) [SerializeField] Renderer m_OutputRenderer = null; // Specifies the output surface/renderer [SerializeField] LayerType m_Type; + + public Camera sourceCamera => m_Camera; [SerializeField] Camera m_Camera = null; // The source camera for the layer (were we get the default properties). The actual rendering, with overridden properties is done by the m_LayerCamera [SerializeField] VideoPlayer m_InputVideo = null; [SerializeField] Texture m_InputTexture = null; @@ -131,6 +133,13 @@ public float aspectRatio [SerializeField] Camera m_LayerCamera; + // Returns true if this layer is using a camera that was cloned internally for drawing + bool isUsingACameraClone => !m_LayerCamera.Equals(m_Camera); + + // The input alpha will be mapped between the min and max range when blending between the post-processed and plain image regions. This way the user can controls how steep is the transition. + [SerializeField] float m_AlphaMin = 0.0f; + [SerializeField] float m_AlphaMax = 1.0f; + private CompositorLayer() { } @@ -210,39 +219,47 @@ public void Init(string layerID = "") m_Camera = CompositionManager.GetSceceCamera(); } + var compositor = CompositionManager.GetInstance(); + // Create a new camera if necessary or use the one specified by the user if (m_LayerCamera == null && m_OutputTarget == OutputTarget.CameraStack) { - - // Clone the camera that was given by the user. We avoid calling Instantiate because we don't want to clone any other children that might be attachen to the camera - var newCameraGameObject = new GameObject("Layer " + layerID) + if (!compositor.IsThisCameraShared(m_Camera)) { - hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy | HideFlags.HideAndDontSave - }; - m_LayerCamera = newCameraGameObject.AddComponent(); - newCameraGameObject.AddComponent(); - CopyInternalCameraData(); - - m_LayerCamera.name = "Compositor" + layerID; - m_LayerCamera.gameObject.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy | HideFlags.HideAndDontSave; - if(m_LayerCamera.tag == "MainCamera") - { - m_LayerCamera.tag = "Untagged"; + // The camera is not shared, so it is safe to use it directly in the layer (no need to clone it) + m_LayerCamera = m_Camera; } - - // Remove the compositor copy (if exists) from the cloned camera. This will happen if the compositor script was attached to the camera we are cloning - var compositionManager = m_LayerCamera.GetComponent(); - if (compositionManager != null) + else { - CoreUtils.Destroy(compositionManager); - } + // Clone the camera that was given by the user. We avoid calling Instantiate because we don't want to clone any other children that might be attachen to the camera + var newCameraGameObject = new GameObject("Layer " + layerID) + { + hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy | HideFlags.HideAndDontSave + }; + m_LayerCamera = newCameraGameObject.AddComponent(); + newCameraGameObject.AddComponent(); + CopyInternalCameraData(); + + m_LayerCamera.name = "Compositor" + layerID; + m_LayerCamera.gameObject.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy | HideFlags.HideAndDontSave; + if (m_LayerCamera.tag == "MainCamera") + { + m_LayerCamera.tag = "Untagged"; + } - var cameraData = m_LayerCamera.GetComponent(); - if (cameraData == null) - { - m_LayerCamera.gameObject.AddComponent(typeof(HDAdditionalCameraData)); - } + // Remove the compositor copy (if exists) from the cloned camera. This will happen if the compositor script was attached to the camera we are cloning + var compositionManager = m_LayerCamera.GetComponent(); + if (compositionManager != null) + { + CoreUtils.Destroy(compositionManager); + } + var cameraData = m_LayerCamera.GetComponent(); + if (cameraData == null) + { + m_LayerCamera.gameObject.AddComponent(typeof(HDAdditionalCameraData)); + } + } } m_ClearsBackGround = false; m_LayerPositionInStack = 0; // will be set in SetupLayerCamera @@ -299,7 +316,6 @@ public void Init(string layerID = "") } } - var compositor = CompositionManager.GetInstance(); if (m_OutputRenderer != null && Application.IsPlaying(compositor.gameObject)) { MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); @@ -317,7 +333,7 @@ public void Init(string layerID = "") if (layerData == null) { layerData = m_LayerCamera.gameObject.AddComponent(); - layerData.hideFlags = HideFlags.HideAndDontSave; + layerData.hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector; } // Reset the layer params (in case we cloned a camera which already had AdditionalCompositorData) if (layerData != null) @@ -370,7 +386,8 @@ public bool Validate() public void DestroyRT() { - if (m_LayerCamera != null) + // We should destroy the layer camera only if it was cloned + if (m_LayerCamera != null && isUsingACameraClone) { var cameraData = m_LayerCamera.GetComponent(); if (cameraData) @@ -456,12 +473,21 @@ public void SetAdditionalLayerData() if (layerData != null) { layerData.Init(m_InputFilters, m_ClearAlpha); + + layerData.alphaMin = m_AlphaMin; + layerData.alphaMax = m_AlphaMax; } } } internal void CopyInternalCameraData() { + if (!isUsingACameraClone) + { + // we are using directly the source camera, so there is no need to copy any properties + return; + } + // Copy/update the camera data (but preserve the camera depth/draw-order [case 1264552]) var drawOrder = m_LayerCamera.depth; m_LayerCamera.CopyFrom(m_Camera); @@ -488,7 +514,7 @@ public void UpdateOutputCamera() if (m_Type == LayerType.Image) { var compositorData = m_LayerCamera.GetComponent(); - if(compositorData) + if (compositorData) compositorData.clearColorTexture = (m_Show && m_InputTexture != null) ? m_InputTexture : Texture2D.blackTexture; } @@ -586,7 +612,7 @@ public void SetupLayerCamera(CompositorLayer targetLayer, int layerPositionInSta var cameraData = m_LayerCamera.GetComponent(); m_LayerCamera.targetTexture = targetLayer.GetRenderTarget(false); - if (targetLayer.m_AOVBitmask == 0) + // Setup the custom clear pass for camera stacking { if (layerPositionInStack != 0) { @@ -599,7 +625,8 @@ public void SetupLayerCamera(CompositorLayer targetLayer, int layerPositionInSta } if (m_Type != LayerType.Image) { - compositorData.clearColorTexture = targetLayer.GetRenderTarget(false); + compositorData.clearColorTexture = targetLayer.GetRenderTarget(); + compositorData.clearDepthTexture = targetLayer.m_RTHandle; } cameraData.volumeLayerMask |= 1 << 31; } @@ -612,7 +639,7 @@ public void SetupLayerCamera(CompositorLayer targetLayer, int layerPositionInSta // The target layer expects AOVs, so this stacked layer should also generate AOVs int aovMask = (1 << (int)targetLayer.m_AOVBitmask); - if (aovMask > 1) + if (m_Show && aovMask > 1) { var aovRequestBuilder = new AOVRequestBuilder(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs index ac12a7f6235..34641d061a7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/CompositionManager.cs @@ -797,6 +797,27 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera) CommandBufferPool.Release(cmd); } + /// + /// Helper function that indicates if a camera is shared between multiple layers + /// + /// The input camera + /// Returns true if this camera is used to render in more than one layer + internal bool IsThisCameraShared(Camera camera) + { + int count = 0; + foreach (var layer in m_InputLayers) + { + + if (layer.outputTarget == CompositorLayer.OutputTarget.CameraStack && + camera.Equals(layer.sourceCamera)) + { + count++; + } + } + // If we found the camera in more than one layer then it is shared between layers + return count > 1; + } + static public Camera GetSceceCamera() { if (Camera.main != null) @@ -817,5 +838,62 @@ static public Camera GetSceceCamera() static public CompositionManager GetInstance() => s_CompositorInstance ?? (s_CompositorInstance = GameObject.FindObjectOfType(typeof(CompositionManager), true) as CompositionManager); + static public Vector4 GetAlphaScaleAndBiasForCamera(HDCamera hdCamera) + { + AdditionalCompositorData compositorData = null; + hdCamera.camera.TryGetComponent(out compositorData); + + if (compositorData) + { + float alphaMin = compositorData.alphaMin; + float alphaMax = compositorData.alphaMax; + + if (alphaMax == alphaMin) + alphaMax += 0.0001f; // Mathf.Epsilon is too small and in this case it creates precission issues + + float alphaScale = 1.0f / (alphaMax - alphaMin); + float alphaBias = -alphaMin * alphaScale; + + return new Vector4(alphaScale, alphaBias, 0.0f, 0.0f); + } + + // No compositor-specific data for this camera/layer, just return the default/neutral scale and bias + return new Vector4(1.0f, 0.0f, 0.0f, 0.0f); + } + + /// + /// For stacked cameras, returns the color buffer that will be used to draw on top + /// + /// The input camera + /// The color buffer that will be used to draw on top, or null if not a stacked camera + static internal Texture GetClearTextureForStackedCamera(HDCamera hdCamera) + { + AdditionalCompositorData compositorData = null; + hdCamera.camera.TryGetComponent(out compositorData); + + if (compositorData) + { + return compositorData.clearColorTexture; + } + return null; + } + + /// + /// For stacked cameras, returns the depth buffer that will be used to draw on top + /// + /// The input camera + /// The depth buffer that will be used to draw on top, or null if not a stacked camera + static internal RenderTexture GetClearDepthForStackedCamera(HDCamera hdCamera) + { + AdditionalCompositorData compositorData = null; + hdCamera.camera.TryGetComponent(out compositorData); + + if (compositorData) + { + return compositorData.clearDepthTexture; + } + return null; + } + } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index e110f438785..1590e2f9d26 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -1314,7 +1314,7 @@ void RegisterLightingDebug() children = { - new DebugUI.FloatField { displayName = "Debug Mip", getter = () => data.fullscreenDebugMip, setter = value => data.fullscreenDebugMip = value, min = () => 0f, max = () => 1f, incStep = 0.05f }, + new DebugUI.FloatField { displayName = "Debug Mip", getter = () => data.fullscreenDebugMip, setter = value => data.fullscreenDebugMip = value, min = () => 0f, max = () => 1f, incStep = 0.05f }, new DebugUI.BoolField { displayName = "Enable Depth Remap", getter = () => data.enableDebugDepthRemap, setter = value => data.enableDebugDepthRemap = value }, new DebugUI.FloatField { displayName = "Depth range min value", getter = () => data.fullScreenDebugDepthRemap.x, setter = value => data.fullScreenDebugDepthRemap.x = value, min = () => 0f, max = () => 1f, incStep = 0.05f }, new DebugUI.FloatField { displayName = "Depth range max value", getter = () => data.fullScreenDebugDepthRemap.y, setter = value => data.fullScreenDebugDepthRemap.y = value, min = () => 0f, max = () => 1f, incStep = 0.05f } @@ -1748,7 +1748,7 @@ void RegisterRenderingDebug() widgetList.Add(new DebugUI.BoolField { displayName = "XR single-pass test mode", getter = () => data.xrSinglePassTestMode, setter = value => data.xrSinglePassTestMode = value }); } - // widgetList.Add(new DebugUI.BoolField { displayName = "Enable Render Graph", getter = () => HDRenderPipeline.currentPipeline.IsRenderGraphEnabled(), setter = value => HDRenderPipeline.currentPipeline.EnableRenderGraph(value) }); + widgetList.Add(new DebugUI.BoolField { displayName = "Enable Render Graph", getter = () => HDRenderPipeline.currentPipeline.IsRenderGraphEnabled(), setter = value => HDRenderPipeline.currentPipeline.EnableRenderGraph(value) }); m_DebugRenderingItems = widgetList.ToArray(); var panel = DebugManager.instance.GetPanel(k_PanelRendering, true); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugLightVolumes.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugLightVolumes.cs index a47709bdaaf..c954fdff596 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugLightVolumes.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugLightVolumes.cs @@ -54,8 +54,6 @@ public void InitData(RenderPipelineResources renderPipelineResources) m_ColorGradientTexture = renderPipelineResources.textures.colorGradient; m_Blit = CoreUtils.CreateEngineMaterial(renderPipelineResources.shaders.blitPS); - - InitializeNonRenderGraphResources(); } public void ReleaseData() diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs new file mode 100644 index 00000000000..90ab3ff0c1e --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs @@ -0,0 +1,38 @@ +namespace UnityEngine.Rendering.HighDefinition +{ + public class DebugOverlay + { + public int x { get; private set; } + public int y { get; private set; } + public int overlaySize { get; private set; } + + int m_InitialPositionX; + int m_ScreenWidth; + + public void StartOverlay(int initialX, int initialY, int overlaySize, int screenWidth) + { + x = initialX; + y = initialY; + this.overlaySize = overlaySize; + + m_InitialPositionX = initialX; + m_ScreenWidth = screenWidth; + } + + public void Next() + { + x += overlaySize; + // Go to next line if it goes outside the screen. + if ((x + overlaySize) > m_ScreenWidth) + { + x = m_InitialPositionX; + y -= overlaySize; + } + } + + public void SetViewport(CommandBuffer cmd) + { + cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs.meta new file mode 100644 index 00000000000..3bc8fafdbb3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugOverlay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cfb9091a8d8a8e24b90601a9e58c108c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/RayCountManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/RayCountManager.cs index 730da2770a5..05a5db62144 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/RayCountManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/RayCountManager.cs @@ -63,9 +63,6 @@ public void Init(HDRenderPipelineRayTracingResources rayTracingResources) // Keep track of the compute shader we are going to use rayCountCS = rayTracingResources.countTracedRays; - // Allocate the texture that will hold the ray count - m_RayCountTexture = RTHandles.Alloc(Vector2.one, slices: TextureXR.slices * (int)RayCountValues.Count, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16_UInt, dimension: TextureDimension.Tex2DArray, enableRandomWrite: true, useMipMap: false, name: "RayCountTextureDebug"); - // We only require 3 buffers (this supports a maximal size of 8192x8192) m_ReducedRayCountBuffer0 = new ComputeBuffer((int)RayCountValues.Count * 256 * 256, sizeof(uint)); m_ReducedRayCountBuffer1 = new ComputeBuffer((int)RayCountValues.Count * 32 * 32, sizeof(uint)); @@ -84,12 +81,23 @@ public void Init(HDRenderPipelineRayTracingResources rayTracingResources) public void Release() { - RTHandles.Release(m_RayCountTexture); CoreUtils.SafeRelease(m_ReducedRayCountBuffer0); CoreUtils.SafeRelease(m_ReducedRayCountBuffer1); CoreUtils.SafeRelease(m_ReducedRayCountBuffer2); } + public void InitializeNonRenderGraphResources() + { + // Allocate the texture that will hold the ray count + m_RayCountTexture = RTHandles.Alloc(Vector2.one, slices: TextureXR.slices * (int)RayCountValues.Count, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16_UInt, dimension: TextureDimension.Tex2DArray, enableRandomWrite: true, useMipMap: false, name: "RayCountTextureDebug"); + } + + public void CleanupNonRenderGraphResources() + { + RTHandles.Release(m_RayCountTexture); + m_RayCountTexture = null; + } + public void ClearRayCount(CommandBuffer cmd, HDCamera camera, bool isActive) { m_IsActive = isActive; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs index 0ecb713eca7..97c9528f841 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs @@ -241,8 +241,7 @@ public bool secondDenoiserPass // RTGI [SerializeField, FormerlySerializedAs("rayLength")] - [Tooltip("Controls the length of GI rays.")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(50.0f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("clampValue")] [Tooltip("Controls the clamp of intensity.")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute index 32274fae94b..941732df6da 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/ClearLightLists.compute @@ -1,11 +1,14 @@ #pragma kernel ClearList RWStructuredBuffer _LightListToClear; -int _LightListEntries; +int2 _LightListEntriesAndOffset; + +#define _LightListEntries (uint)_LightListEntriesAndOffset.x +#define _LightListOffset (uint)_LightListEntriesAndOffset.y [numthreads(64, 1, 1)] void ClearList(uint3 id : SV_DispatchThreadID) { - if (id.x < (uint)_LightListEntries) - _LightListToClear[id.x] = 0; + if ((id.x + _LightListOffset) < (uint)_LightListEntries) + _LightListToClear[id.x + _LightListOffset] = 0; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightCullUtils.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightCullUtils.hlsl index ea8d937ca7c..4a2a69df125 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightCullUtils.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightCullUtils.hlsl @@ -3,31 +3,33 @@ // Used to index into our SFiniteLightBound (g_data) and // LightVolumeData (_LightVolumeData) buffers. -int GenerateLightCullDataIndex(int lightIndex, uint numVisibleLights, uint eyeIndex) +uint GenerateLightCullDataIndex(uint lightIndex, uint numVisibleLights, uint eyeIndex) { + lightIndex = min(lightIndex, numVisibleLights - 1); // Stay within bounds + // For monoscopic, there is just one set of light cull data structs. // In stereo, all of the left eye structs are first, followed by the right eye structs. - const int perEyeBaseIndex = (int)eyeIndex * (int)numVisibleLights; + const uint perEyeBaseIndex = eyeIndex * numVisibleLights; return (perEyeBaseIndex + lightIndex); } struct ScreenSpaceBoundsIndices { - int min; - int max; + uint min; + uint max; }; // The returned values are used to index into our AABB screen space bounding box buffer // Usually named g_vBoundsBuffer. The two values represent the min/max indices. -ScreenSpaceBoundsIndices GenerateScreenSpaceBoundsIndices(int lightIndex, uint numVisibleLights, uint eyeIndex) +ScreenSpaceBoundsIndices GenerateScreenSpaceBoundsIndices(uint lightIndex, uint numVisibleLights, uint eyeIndex) { // In the monoscopic mode, there is one set of bounds (min,max -> 2 * g_iNrVisibLights) // In stereo, there are two sets of bounds (leftMin, leftMax, rightMin, rightMax -> 4 * g_iNrVisibLights) - const int eyeRelativeBase = (int)eyeIndex * 2 * (int)numVisibleLights; + const uint eyeRelativeBase = eyeIndex * 2 * numVisibleLights; ScreenSpaceBoundsIndices indices; indices.min = eyeRelativeBase + lightIndex; - indices.max = eyeRelativeBase + lightIndex + (int)numVisibleLights; + indices.max = indices.min + numVisibleLights; return indices; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 30671f5e233..0e390699687 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -130,8 +130,8 @@ struct SFiniteLightBound public Vector3 boxAxisY; // Scaled by the extents (half-size) public Vector3 boxAxisZ; // Scaled by the extents (half-size) public Vector3 center; // Center of the bounds (box) in camera space - public Vector2 scaleXY; // Scale applied to the top of the box to turn it into a truncated pyramid - public float radius; // Circumscribed sphere for the bounds (box) + public float scaleXY; // Scale applied to the top of the box to turn it into a truncated pyramid (X = Y) + public float radius; // Circumscribed sphere for the bounds (box) }; [GenerateHLSL] @@ -696,7 +696,6 @@ enum ClusterDepthSource : int { "TileLightListGen_NoDepthRT_SrcBigTile", "TileLightListGen_DepthRT_SrcBigTile_Oblique", "TileLightListGen_DepthRT_MSAA_SrcBigTile_Oblique" } }; - static int s_GenAABBKernel; static int s_GenListPerTileKernel; static int[,] s_ClusterKernels = new int[(int)ClusterPrepassSource.Count, (int)ClusterDepthSource.Count]; static int[,] s_ClusterObliqueKernels = new int[(int)ClusterPrepassSource.Count, (int)ClusterDepthSource.Count]; @@ -879,8 +878,6 @@ void InitializeLightLoop(IBLFilterBSDF[] iBLFilterBSDFArray) m_MaxLightsOnScreen = m_MaxDirectionalLightsOnScreen + m_MaxPunctualLightsOnScreen + m_MaxAreaLightsOnScreen + m_MaxEnvLightsOnScreen; m_MaxPlanarReflectionOnScreen = lightLoopSettings.maxPlanarReflectionOnScreen; - s_GenAABBKernel = buildScreenAABBShader.FindKernel("ScreenBoundsAABB"); - // Cluster { s_ClearVoxelAtomicKernel = clearClusterAtomicIndexShader.FindKernel("ClearAtomic"); @@ -1766,9 +1763,9 @@ void GetLightVolumeDataAndBound(LightCategory lightCategory, GPULightType gpuLig fAltDx *= range; fAltDy *= range; // Handle case of pyramid with this select (currently unused) - var altDist = Mathf.Sqrt(fAltDy * fAltDy + (true ? 1.0f : 2.0f) * fAltDx * fAltDx); - bound.radius = altDist > (0.5f * range) ? altDist : (0.5f * range); // will always pick fAltDist - bound.scaleXY = squeeze ? new Vector2(0.01f, 0.01f) : new Vector2(1.0f, 1.0f); + var altDist = Mathf.Sqrt(fAltDy * fAltDy + (true ? 1.0f : 2.0f) * fAltDx * fAltDx); + bound.radius = altDist > (0.5f * range) ? altDist : (0.5f * range); // will always pick fAltDist + bound.scaleXY = squeeze ? 0.01f : 1.0f; lightVolumeData.lightAxisX = vx; lightVolumeData.lightAxisY = vy; @@ -1780,16 +1777,19 @@ void GetLightVolumeDataAndBound(LightCategory lightCategory, GPULightType gpuLig } else if (gpuLightType == GPULightType.Point) { - Vector3 vx = xAxisVS; - Vector3 vy = yAxisVS; - Vector3 vz = zAxisVS; + // Construct a view-space axis-aligned bounding cube around the bounding sphere. + // This allows us to utilize the same polygon clipping technique for all lights. + // Non-axis-aligned vectors may result in a larger screen-space AABB. + Vector3 vx = new Vector3(1, 0, 0); + Vector3 vy = new Vector3(0, 1, 0); + Vector3 vz = new Vector3(0, 0, 1); bound.center = positionVS; bound.boxAxisX = vx * range; bound.boxAxisY = vy * range; bound.boxAxisZ = vz * range; - bound.scaleXY.Set(1.0f, 1.0f); - bound.radius = range; + bound.scaleXY = 1.0f; + bound.radius = range; // fill up ldata lightVolumeData.lightAxisX = vx; @@ -1810,7 +1810,7 @@ void GetLightVolumeDataAndBound(LightCategory lightCategory, GPULightType gpuLig bound.boxAxisY = extents.y * yAxisVS; bound.boxAxisZ = extents.z * zAxisVS; bound.radius = extents.magnitude; - bound.scaleXY.Set(1.0f, 1.0f); + bound.scaleXY = 1.0f; lightVolumeData.lightPos = centerVS; lightVolumeData.lightAxisX = xAxisVS; @@ -1830,7 +1830,7 @@ void GetLightVolumeDataAndBound(LightCategory lightCategory, GPULightType gpuLig bound.boxAxisY = extents.y * yAxisVS; bound.boxAxisZ = extents.z * zAxisVS; bound.radius = extents.magnitude; - bound.scaleXY.Set(1.0f, 1.0f); + bound.scaleXY = 1.0f; lightVolumeData.lightPos = centerVS; lightVolumeData.lightAxisX = xAxisVS; @@ -1850,7 +1850,7 @@ void GetLightVolumeDataAndBound(LightCategory lightCategory, GPULightType gpuLig bound.boxAxisY = extents.y * yAxisVS; bound.boxAxisZ = extents.z * zAxisVS; bound.radius = extents.magnitude; - bound.scaleXY.Set(1.0f, 1.0f); + bound.scaleXY = 1.0f; lightVolumeData.lightPos = centerVS; lightVolumeData.lightAxisX = xAxisVS; @@ -2065,8 +2065,8 @@ void GetEnvLightVolumeDataAndBound(HDProbe probe, LightVolumeType lightVolumeTyp bound.boxAxisX = influenceRightVS * influenceExtents.x; bound.boxAxisY = influenceUpVS * influenceExtents.x; bound.boxAxisZ = influenceForwardVS * influenceExtents.x; - bound.scaleXY.Set(1.0f, 1.0f); - bound.radius = influenceExtents.x; + bound.scaleXY = 1.0f; + bound.radius = influenceExtents.x; break; } case LightVolumeType.Box: @@ -2075,8 +2075,8 @@ void GetEnvLightVolumeDataAndBound(HDProbe probe, LightVolumeType lightVolumeTyp bound.boxAxisX = influenceExtents.x * influenceRightVS; bound.boxAxisY = influenceExtents.y * influenceUpVS; bound.boxAxisZ = influenceExtents.z * influenceForwardVS; - bound.scaleXY.Set(1.0f, 1.0f); - bound.radius = influenceExtents.magnitude; + bound.scaleXY = 1.0f; + bound.radius = influenceExtents.magnitude; // The culling system culls pixels that are further // than a threshold to the box influence extents. @@ -2124,7 +2124,7 @@ void CreateBoxVolumeDataAndBound(OrientedBBox obb, LightCategory category, Light bound.boxAxisY = extentConservativeY * upVS; bound.boxAxisZ = extentConservativeZ * forwardVS; bound.radius = extentConservativeMagnitude; - bound.scaleXY.Set(1.0f, 1.0f); + bound.scaleXY = 1.0f; // The culling system culls pixels that are further // than a threshold to the box influence extents. @@ -3059,10 +3059,26 @@ BuildGPULightListResources PrepareBuildGPULightListResources(TileAndClusterData static void ClearLightList(in BuildGPULightListParameters parameters, CommandBuffer cmd, ComputeBuffer bufferToClear) { cmd.SetComputeBufferParam(parameters.clearLightListCS, parameters.clearLightListKernel, HDShaderIDs._LightListToClear, bufferToClear); - cmd.SetComputeIntParam(parameters.clearLightListCS, HDShaderIDs._LightListEntries, bufferToClear.count); + Vector2 countAndOffset = new Vector2Int(bufferToClear.count, 0); int groupSize = 64; - cmd.DispatchCompute(parameters.clearLightListCS, parameters.clearLightListKernel, (bufferToClear.count + groupSize - 1) / groupSize, 1, 1); + int totalNumberOfGroupsNeeded = (bufferToClear.count + groupSize - 1) / groupSize; + + const int maxAllowedGroups = 65535; + // On higher resolutions we might end up with more than 65535 group which is not allowed, so we need to to have multiple dispatches. + int i = 0; + while(totalNumberOfGroupsNeeded > 0) + { + countAndOffset.y = maxAllowedGroups * i; + cmd.SetComputeVectorParam(parameters.clearLightListCS, HDShaderIDs._LightListEntriesAndOffset, countAndOffset); + + int currGroupCount = Math.Min(maxAllowedGroups, totalNumberOfGroupsNeeded); + + cmd.DispatchCompute(parameters.clearLightListCS, parameters.clearLightListKernel, currGroupCount, 1, 1); + + totalNumberOfGroupsNeeded -= currGroupCount; + i++; + } } static void ClearLightLists( in BuildGPULightListParameters parameters, @@ -3087,13 +3103,21 @@ static void GenerateLightsScreenSpaceAABBs(in BuildGPULightListParameters parame { if (parameters.totalLightCount != 0) { - // With XR single-pass, we have one set of light bounds per view to iterate over (bounds are in view space for each view) - cmd.SetComputeBufferParam(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, HDShaderIDs.g_data, resources.convexBoundsBuffer); - cmd.SetComputeBufferParam(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, HDShaderIDs.g_vBoundsBuffer, resources.AABBBoundsBuffer); + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.GenerateLightAABBs))) + { + // With XR single-pass, we have one set of light bounds per view to iterate over (bounds are in view space for each view) + cmd.SetComputeBufferParam(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, HDShaderIDs.g_data, resources.convexBoundsBuffer); + cmd.SetComputeBufferParam(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, HDShaderIDs.g_vBoundsBuffer, resources.AABBBoundsBuffer); + + ConstantBuffer.Push(cmd, parameters.lightListCB, parameters.screenSpaceAABBShader, HDShaderIDs._ShaderVariablesLightList); - ConstantBuffer.Push(cmd, parameters.lightListCB, parameters.screenSpaceAABBShader, HDShaderIDs._ShaderVariablesLightList); + const int threadsPerLight = 4; // Shader: THREADS_PER_LIGHT (4) + const int threadsPerGroup = 64; // Shader: THREADS_PER_GROUP (64) - cmd.DispatchCompute(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, (parameters.totalLightCount + 7) / 8, parameters.viewCount, 1); + int groupCount = HDUtils.DivRoundUp(parameters.totalLightCount * threadsPerLight, threadsPerGroup); + + cmd.DispatchCompute(parameters.screenSpaceAABBShader, parameters.screenSpaceAABBKernel, groupCount, parameters.viewCount, 1); + } } } @@ -3175,15 +3199,16 @@ static void VoxelLightListGeneration(in BuildGPULightListParameters parameters, cmd.DispatchCompute(parameters.clearClusterAtomicIndexShader, s_ClearVoxelAtomicKernel, 1, 1, 1); cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, s_ClearVoxelAtomicKernel, HDShaderIDs.g_LayeredSingleIdxBuffer, resources.globalLightListAtomic); - cmd.SetComputeTextureParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_depth_tex, resources.depthBuffer); cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_vLayeredLightList, resources.perVoxelLightLists); cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_LayeredOffset, resources.perVoxelOffset); cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_LayeredSingleIdxBuffer, resources.globalLightListAtomic); + if (parameters.runBigTilePrepass) cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_vBigTileLightList, resources.bigTileLightList); if (parameters.clusterNeedsDepth) { + cmd.SetComputeTextureParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_depth_tex, resources.depthBuffer); cmd.SetComputeBufferParam(parameters.buildPerVoxelLightListShader, parameters.buildPerVoxelLightListKernel, HDShaderIDs.g_logBaseBuffer, resources.perTileLogBaseTweak); } @@ -3408,12 +3433,7 @@ unsafe BuildGPULightListParameters PrepareBuildGPULightListParameters( HDCamera // Screen space AABB parameters.screenSpaceAABBShader = buildScreenAABBShader; - parameters.screenSpaceAABBShader.shaderKeywords = null; - if (isProjectionOblique) - { - parameters.screenSpaceAABBShader.EnableKeyword("USE_OBLIQUE_MODE"); - } - parameters.screenSpaceAABBKernel = s_GenAABBKernel; + parameters.screenSpaceAABBKernel = 0; // Big tile prepass parameters.runBigTilePrepass = hdCamera.frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass); @@ -4164,9 +4184,6 @@ LightLoopDebugOverlayParameters PrepareLightLoopDebugOverlayParameters() static void RenderLightLoopDebugOverlay(in DebugParameters debugParameters, CommandBuffer cmd, - ref float x, - ref float y, - float overlaySize, ComputeBuffer tileBuffer, ComputeBuffer lightListBuffer, ComputeBuffer perVoxelLightListBuffer, @@ -4243,9 +4260,9 @@ static void RenderLightLoopDebugOverlay(in DebugParameters debugParameters, m_LightLoopDebugMaterialProperties.SetFloat(HDShaderIDs._ApplyExposure, 0.0f); m_LightLoopDebugMaterialProperties.SetFloat(HDShaderIDs._Mipmap, lightingDebug.cookieAtlasMipLevel); m_LightLoopDebugMaterialProperties.SetTexture(HDShaderIDs._InputTexture, parameters.cookieManager.atlasTexture); - cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); + debugParameters.debugOverlay.SetViewport(cmd); cmd.DrawProcedural(Matrix4x4.identity, parameters.debugBlitMaterial, 0, MeshTopology.Triangles, 3, 1, m_LightLoopDebugMaterialProperties); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + debugParameters.debugOverlay.Next(); } } @@ -4261,14 +4278,14 @@ static void RenderLightLoopDebugOverlay(in DebugParameters debugParameters, m_LightLoopDebugMaterialProperties.SetFloat(HDShaderIDs._ApplyExposure, 1.0f); m_LightLoopDebugMaterialProperties.SetFloat(HDShaderIDs._Mipmap, lightingDebug.planarReflectionProbeMipLevel); m_LightLoopDebugMaterialProperties.SetTexture(HDShaderIDs._InputTexture, parameters.planarProbeCache.GetTexCache()); - cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); + debugParameters.debugOverlay.SetViewport(cmd); cmd.DrawProcedural(Matrix4x4.identity, parameters.debugBlitMaterial, 0, MeshTopology.Triangles, 3, 1, m_LightLoopDebugMaterialProperties); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + debugParameters.debugOverlay.Next(); } } } - static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDShadowManager.ShadowDebugAtlasTextures atlasTextures, CommandBuffer cmd, ref float x, ref float y, float overlaySize, MaterialPropertyBlock mpb) + static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDShadowManager.ShadowDebugAtlasTextures atlasTextures, CommandBuffer cmd, MaterialPropertyBlock mpb) { LightingDebugSettings lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; if (lightingDebug.shadowDebugMode != ShadowMapDebugMode.None) @@ -4302,29 +4319,29 @@ static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDS for (int shadowIndex = startShadowIndex; shadowIndex < startShadowIndex + shadowRequestCount; shadowIndex++) { - parameters.shadowManager.DisplayShadowMap(atlasTextures, shadowIndex, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayShadowMap(atlasTextures, shadowIndex, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); } break; case ShadowMapDebugMode.VisualizePunctualLightAtlas: - parameters.shadowManager.DisplayShadowAtlas(atlasTextures.punctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayShadowAtlas(atlasTextures.punctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); break; case ShadowMapDebugMode.VisualizeCachedPunctualLightAtlas: - parameters.shadowManager.DisplayCachedPunctualShadowAtlas(atlasTextures.cachedPunctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayCachedPunctualShadowAtlas(atlasTextures.cachedPunctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); break; case ShadowMapDebugMode.VisualizeDirectionalLightAtlas: - parameters.shadowManager.DisplayShadowCascadeAtlas(atlasTextures.cascadeShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayShadowCascadeAtlas(atlasTextures.cascadeShadowAtlas, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); break; case ShadowMapDebugMode.VisualizeAreaLightAtlas: - parameters.shadowManager.DisplayAreaLightShadowAtlas(atlasTextures.areaShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayAreaLightShadowAtlas(atlasTextures.areaShadowAtlas, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); break; case ShadowMapDebugMode.VisualizeCachedAreaLightAtlas: - parameters.shadowManager.DisplayCachedAreaShadowAtlas(atlasTextures.cachedAreaShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + parameters.shadowManager.DisplayCachedAreaShadowAtlas(atlasTextures.cachedAreaShadowAtlas, cmd, parameters.debugShadowMapMaterial, debugParameters.debugOverlay.x, debugParameters.debugOverlay.y, debugParameters.debugOverlay.overlaySize, debugParameters.debugOverlay.overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + debugParameters.debugOverlay.Next(); break; default: break; @@ -4332,25 +4349,6 @@ static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDS } } } - - static void RenderProbeVolumeDebugOverlay(in DebugParameters debugParameters, CommandBuffer cmd, ref float x, ref float y, float overlaySize, Material debugDisplayProbeVolumeMaterial) - { - LightingDebugSettings lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; - if (lightingDebug.probeVolumeDebugMode != ProbeVolumeDebugMode.None) - { - using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ProbeVolumeDebug))) - { - if (lightingDebug.probeVolumeDebugMode == ProbeVolumeDebugMode.VisualizeAtlas) - { - HDRenderPipeline hdrp = RenderPipelineManager.currentPipeline as HDRenderPipeline; - HDCamera hdCamera = debugParameters.hdCamera; - hdrp.DisplayProbeVolumeAtlas(cmd, debugDisplayProbeVolumeMaterial, x, y, overlaySize, overlaySize, lightingDebug.probeVolumeMinValue, lightingDebug.probeVolumeMaxValue, (int)lightingDebug.probeVolumeAtlasSliceMode); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); - } - - } - } - } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl index f4a18fa8f36..dc8f41cf636 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl @@ -74,7 +74,7 @@ struct SFiniteLightBound float3 boxAxisY; float3 boxAxisZ; float3 center; - float2 scaleXY; + float scaleXY; float radius; }; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/scrbound.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/scrbound.compute index be07511307d..2f52532ac61 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/scrbound.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/scrbound.compute @@ -1,533 +1,734 @@ -// The implementation is based on the demo on "fine pruned tiled lighting" published in GPU Pro 7. -// https://github.com/wolfgangfengel/GPU-Pro-7 - -#pragma kernel ScreenBoundsAABB - -#pragma multi_compile _ USE_OBLIQUE_MODE +// #pragma enable_d3d11_debug_symbols +#pragma only_renderers d3d11 playstation xboxone vulkan metal switch +#pragma kernel main #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl" #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/LightCullUtils.hlsl" -#pragma only_renderers d3d11 playstation xboxone vulkan metal switch +/* ------------------------------ Inputs ------------------------------------ */ + +StructuredBuffer g_data : register(t0); -StructuredBuffer g_data : register( t0 ); +/* ------------------------------ Outputs ----------------------------------- */ -#define NR_THREADS 64 +RWStructuredBuffer g_vBoundsBuffer : register(u0); -// output buffer -RWStructuredBuffer g_vBoundsBuffer : register( u0 ); +/* ------------------------------ Utilities --------------------------------- */ -#define MAX_PNTS 9 // strictly this should be 10=6+4 but we get more wavefronts and 10 seems to never hit (fingers crossed) - // However, worst case the plane that would be skipped if such an extreme case ever happened would be backplane - // clipping gets skipped which doesn't cause any errors. +// Returns the location of the N-th set bit starting from the lowest order bit and working upward. +// Slow implementation - do not use for large bit sets. +// Could be optimized - see https://graphics.stanford.edu/~seander/bithacks.html +uint NthBitLow(uint value, uint n) +{ + uint b = -1; // Consistent with the behavior of firstbitlow() + uint c = countbits(value); + if (n < c) // Validate inputs + { + uint r = n + 1; // Compute the number of remaining bits -// LDS (2496 bytes) -groupshared float posX[MAX_PNTS*8*2]; -groupshared float posY[MAX_PNTS*8*2]; -groupshared float posZ[MAX_PNTS*8*2]; -groupshared float posW[MAX_PNTS*8*2]; -groupshared unsigned int clipFlags[48]; + do + { + uint f = firstbitlow(value >> (b + 1)); // Find the next set bit + b += f + r; // Make a guess (assume all [b+f+1,b+f+r] bits are set) + c = countbits(value << (32 - (b + 1))); // Count the number of bits actually set + r = (n + 1) - c; // Compute the number of remaining bits + } while (r > 0); + } + return b; +} -unsigned int GetClip(const float4 P); -int ClipAgainstPlane(const int iSrcIndex, const int iNrSrcVerts, const int subLigt, const int p); -void CalcBound(out bool2 bIsMinValid, out bool2 bIsMaxValid, out float2 vMin, out float2 vMax, float4x4 InvProjection, float3 pos_view_space, float r); +float4x4 Translation4x4(float3 d) +{ + float4x4 M = k_identity4x4; -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightingConvexHullUtils.hlsl" + M._14_24_34 = d; // Last column + return M; +} -[numthreads(NR_THREADS, 1, 1)] -void ScreenBoundsAABB(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID) +// Scale followed by rotation (scaled axes). +float3x3 ScaledRotation3x3(float3 xAxis, float3 yAxis, float3 zAxis) { - uint groupID = u3GroupID.x; - uint eyeIndex = u3GroupID.y; // currently, can only be 0 or 1 + float3x3 R = float3x3(xAxis, yAxis, zAxis); + float3x3 C = transpose(R); // Row to column - // The g_ is preserved in order to make cross-pipeline (FPTL) updates easier - float4x4 g_mInvProjection = g_mInvProjectionArr[eyeIndex]; - float4x4 g_mProjection = g_mProjectionArr[eyeIndex]; + return C; +} - //uint vindex = groupID * NR_THREADS + threadID; - unsigned int g = groupID; - unsigned int t = threadID; +float3x3 Invert3x3(float3x3 R) +{ + float3x3 C = transpose(R); // Row to column + float det = dot(C[0], cross(C[1], C[2])); + float3x3 adj = float3x3(cross(C[1], C[2]), + cross(C[2], C[0]), + cross(C[0], C[1])); + return rcp(det) * adj; +} - const int subLigt = (int) (t/8); - const int lgtIndex = subLigt+(int) g*8; - const int sideIndex = (int) (t%8); +float4x4 Homogenize3x3(float3x3 R) +{ + float4x4 M = float4x4(float4(R[0], 0), + float4(R[1], 0), + float4(R[2], 0), + float4(0,0,0,1)); + return M; +} - const int eyeAdjustedLgtIndex = GenerateLightCullDataIndex(lgtIndex, g_iNrVisibLights, eyeIndex); - SFiniteLightBound lgtDat = g_data[eyeAdjustedLgtIndex]; +float4x4 PerspectiveProjection4x4(float a, float g, float n, float f) +{ + float b = (f + n) * rcp(f - n); // Z in [-1, 1] + float c = -2 * f * n * rcp(f - n); // No Z-reversal - const float3 boxX = lgtDat.boxAxisX.xyz; - const float3 boxY = lgtDat.boxAxisY.xyz; - const float3 boxZ = -lgtDat.boxAxisZ.xyz; // flip axis (so it points away from the light direction for a spot-light) - const float3 center = lgtDat.center.xyz; - const float radius = lgtDat.radius; - const float2 scaleXY = lgtDat.scaleXY; + return float4x4(g/a, 0, 0, 0, + 0, g, 0, 0, + 0, 0, b, c, + 0, 0, 1, 0); +} - { - if(sideIndex<6 && lgtIndex<(int) g_iNrVisibLights) // mask 2 out of 8 threads - { - float3 q0, q1, q2, q3; - GetHullQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, sideIndex); +/* ------------------------------ Implementation ---------------------------- */ +// Improve the quality of generated code at the expense of readability. +// Remove when the shader compiler is clever enough to perform this optimization for us. +#define OBTUSE_COMPILER - const float4 vP0 = mul(g_mProjection, float4(q0, 1)); - const float4 vP1 = mul(g_mProjection, float4(q1, 1)); - const float4 vP2 = mul(g_mProjection, float4(q2, 1)); - const float4 vP3 = mul(g_mProjection, float4(q3, 1)); +#ifdef SHADER_API_XBOXONE +// The Xbox shader compiler expects the lane swizzle mask to be a compile-time constant. +// In our case, the mask is a compile-time constant, but it is defined inside a loop +// that is unrolled at the compile time, and the constants are generated during the +// constant propagation pass of the optimizer. This works fine on PlayStation, but does not work +// on Xbox. In order to avoid writing hideous code specifically for Xbox, we disable the support +// of wave intrinsics on Xbox until the Xbox compiler is fixed. +#undef PLATFORM_SUPPORTS_WAVE_INTRINSICS +#endif - // test vertices of one quad (of the convex hull) for intersection - const unsigned int uFlag0 = GetClip(vP0); - const unsigned int uFlag1 = GetClip(vP1); - const unsigned int uFlag2 = GetClip(vP2); - const unsigned int uFlag3 = GetClip(vP3); +#define CLEAR_SIGN_BIT(X) (asint(X) & INT_MAX) +#define DIV_ROUND_UP(N, D) (((N) + (D) - 1) / (D)) // No division by 0 checks + +// Clipping a plane by a cube may produce a hexagon (6-gon). +// Clipping a hexagon by 4 planes may produce a decagon (10-gon). +#define MAX_CLIP_VERTS (10) +#define NUM_VERTS (8) +#define NUM_FACES (6) +#define NUM_PLANES (6) +#define THREADS_PER_GROUP (64) +#define THREADS_PER_LIGHT (4) // Set to 1 for debugging +#define LIGHTS_PER_GROUP (THREADS_PER_GROUP / THREADS_PER_LIGHT) +#define VERTS_PER_GROUP (NUM_VERTS * LIGHTS_PER_GROUP) +#define VERTS_PER_THREAD (NUM_VERTS / THREADS_PER_LIGHT) +#define FACES_PER_THREAD DIV_ROUND_UP(NUM_FACES, THREADS_PER_LIGHT) + +// All planes and faces are always in the standard order (see below). +// Near and far planes are swapped in the case of Z-reversal, but it does not change the algorithm. +#define FACE_LEFT (1 << 0) // -X z +#define FACE_RIGHT (1 << 1) // +X / +#define FACE_TOP (1 << 2) // -Y 0 -- x +#define FACE_BOTTOM (1 << 3) // +Y | +#define FACE_FRONT (1 << 4) // -Z y +#define FACE_BACK (1 << 5) // +Z +#define FACE_MASK ((1 << NUM_FACES) - 1) + +// A list of vertices for each face (CCW order w.r.t. its normal, starting from the LSB). +#define VERT_LIST_LEFT ((2) << 9 | (6) << 6 | (4) << 3 | (0) << 0) +#define VERT_LIST_RIGHT ((5) << 9 | (7) << 6 | (3) << 3 | (1) << 0) +#define VERT_LIST_TOP ((1) << 9 | (3) << 6 | (2) << 3 | (0) << 0) +#define VERT_LIST_BOTTOM ((6) << 9 | (7) << 6 | (5) << 3 | (4) << 0) +#define VERT_LIST_FRONT ((4) << 9 | (5) << 6 | (1) << 3 | (0) << 0) +#define VERT_LIST_BACK ((3) << 9 | (7) << 6 | (6) << 3 | (2) << 0) + +// All vertices are always in the standard order (see below). +uint GetFaceMaskOfVertex(uint v) +{ + // 0: (-1, -1, -1) -> { FACE_LEFT | FACE_TOP | FACE_FRONT } + // 1: (+1, -1, -1) -> { FACE_RIGHT | FACE_TOP | FACE_FRONT } + // 2: (-1, +1, -1) -> { FACE_LEFT | FACE_BOTTOM | FACE_FRONT } + // 3: (+1, +1, -1) -> { FACE_RIGHT | FACE_BOTTOM | FACE_FRONT } + // 4: (-1, -1, +1) -> { FACE_LEFT | FACE_TOP | FACE_BACK } + // 5: (+1, -1, +1) -> { FACE_RIGHT | FACE_TOP | FACE_BACK } + // 6: (-1, +1, +1) -> { FACE_LEFT | FACE_BOTTOM | FACE_BACK } + // 7: (+1, +1, +1) -> { FACE_RIGHT | FACE_BOTTOM | FACE_BACK } + // ((v & 1) == 0) ? 1 : 2) | ((v & 2) == 0) ? 4 : 8) | ((v & 4) == 0) ? 16 : 32) + uint f = (FACE_LEFT << BitFieldExtract(v, 0, 1)) + | (FACE_TOP << BitFieldExtract(v, 1, 1)) + | (FACE_FRONT << BitFieldExtract(v, 2, 1)); + + return f; +}; + +float3 GenerateVertexOfStandardCube(uint v) +{ + float3 p; - const float4 vPnts[] = {vP0, vP1, vP2, vP3}; + p.x = ((v & 1) == 0) ? -1 : 1; + p.y = ((v & 2) == 0) ? -1 : 1; + p.z = ((v & 4) == 0) ? -1 : 1; - // screen-space AABB of one quad (assuming no intersection) - float3 vMin, vMax; - for(int k=0; k<4; k++) - { - float fW = vPnts[k].w; - float fS = fW<0 ? -1 : 1; - float fWabs = fW<0 ? (-fW) : fW; - fW = fS * (fWabs> 1], 12 * (f & 1), 12); +} - posX[subLigt*MAX_PNTS*2 + sideIndex + 6] = vMax.x; - posY[subLigt*MAX_PNTS*2 + sideIndex + 6] = vMax.y; - posZ[subLigt*MAX_PNTS*2 + sideIndex + 6] = vMax.z; - } +// 5 arrays * 128 elements * 4 bytes each = 2560 bytes. +groupshared float gs_HapVertsX[VERTS_PER_GROUP]; +groupshared float gs_HapVertsY[VERTS_PER_GROUP]; +groupshared float gs_HapVertsZ[VERTS_PER_GROUP]; +groupshared float gs_HapVertsW[VERTS_PER_GROUP]; +groupshared uint gs_BehindMasksOfVerts[VERTS_PER_GROUP]; // 6 planes each (HLSL does not support small data types) + +#ifndef PLATFORM_SUPPORTS_WAVE_INTRINSICS +// 1 array * 16 elements * 4 bytes each = 64 bytes. +groupshared uint gs_CullClipFaceMasks[LIGHTS_PER_GROUP]; // 6 faces each (HLSL does not support small data types) + +// 8 arrays * 16 elements * 4 bytes each = 512 bytes. +// These are actually floats reinterpreted as uints. +// The reason is because floating-point atomic operations are not supported. +groupshared uint gs_NdcAaBbMinPtX[LIGHTS_PER_GROUP]; +groupshared uint gs_NdcAaBbMaxPtX[LIGHTS_PER_GROUP]; +groupshared uint gs_NdcAaBbMinPtY[LIGHTS_PER_GROUP]; +groupshared uint gs_NdcAaBbMaxPtY[LIGHTS_PER_GROUP]; +groupshared uint gs_NdcAaBbMinPtZ[LIGHTS_PER_GROUP]; // Note that min-max Z cannot be trivially reconstructed +groupshared uint gs_NdcAaBbMaxPtZ[LIGHTS_PER_GROUP]; // from min-max W if the projection is oblique. +groupshared uint gs_NdcAaBbMinPtW[LIGHTS_PER_GROUP]; // View-space Z coordinate +groupshared uint gs_NdcAaBbMaxPtW[LIGHTS_PER_GROUP]; // View-space Z coordinate +#endif // PLATFORM_SUPPORTS_WAVE_INTRINSICS + +// Returns 'true' if it manages to cull the face. +bool TryCullFace(uint f, uint behindMasksOfVerts[NUM_VERTS]) +{ + uint cullMaskOfFace = FACE_MASK; // Initially behind + uint vertListOfFace = GetVertexListOfFace(f); + + for (uint j = 0; j < 4; j++) + { + uint v = BitFieldExtract(vertListOfFace, 3 * j, 3); + // Non-zero if ALL the vertices are behind any of the planes. + cullMaskOfFace &= behindMasksOfVerts[v]; } - // if not XBONE and not PLAYSTATION4 we need a memorybarrier here - // since we can't rely on the gpu cores being 64 wide. - // We need a pound define around this. - GroupMemoryBarrierWithGroupSync(); + return (cullMaskOfFace != 0); +} +struct ClipVertex +{ + float4 pt; // Homogeneous coordinate after perspective + float bc; // Boundary coordinate with respect to the plane 'p' +}; - { - int f=0; +ClipVertex CreateClipVertex(uint p, float4 v) +{ + bool evenPlane = (p & 1) == 0; - if(sideIndex==0 && lgtIndex<(int) g_iNrVisibLights) - { - // quick acceptance or rejection - unsigned int uCollectiveAnd = (unsigned int) -1; - unsigned int uCollectiveOr = 0; - for(f=0; f<6; f++) - { - unsigned int uFlagAnd = clipFlags[subLigt*6+f]&0x3f; - unsigned int uFlagOr = uFlagAnd; - for(int i=1; i<4; i++) - { - unsigned int uClipBits = (clipFlags[subLigt*6+f]>>(i*6))&0x3f; - uFlagAnd &= uClipBits; - uFlagOr |= uClipBits; - } + float c = v[p >> 1]; + float w = v.w; - uCollectiveAnd &= uFlagAnd; - uCollectiveOr |= uFlagOr; - } + ClipVertex cv; - bool bSetBoundYet = false; - float3 vMin=0.0, vMax=0.0; - if(uCollectiveAnd!=0 || uCollectiveOr==0) // all invisible or all visible (early out) - { - if(uCollectiveOr==0) // all visible - { - for(f=0; f<6; f++) - { - const int sideIndex = f; - - float3 vFaceMi = float3(posX[subLigt*MAX_PNTS*2 + sideIndex + 0], posY[subLigt*MAX_PNTS*2 + sideIndex + 0], posZ[subLigt*MAX_PNTS*2 + sideIndex + 0]); - float3 vFaceMa = float3(posX[subLigt*MAX_PNTS*2 + sideIndex + 6], posY[subLigt*MAX_PNTS*2 + sideIndex + 6], posZ[subLigt*MAX_PNTS*2 + sideIndex + 6]); - - for(int k=0; k<2; k++) - { - float3 vP = k==0 ? vFaceMi : vFaceMa; - if(f==0 && k==0) { vMin=vP; vMax=vP; } - - vMax = max(vMax, vP); vMin = min(vMin, vP); - } - } - bSetBoundYet=true; - } - } - else // :( need true clipping - { + cv.pt = v; + cv.bc = evenPlane ? c : w - c; // dot(PlaneEquation, HapVertex); - for(f=0; f<6; f++) - { - float3 q0, q1, q2, q3; - GetHullQuad(q0, q1, q2, q3, boxX, boxY, boxZ, center, scaleXY, f); + return cv; +} - // 4 vertices to a quad of the convex hull in post projection space - const float4 vP0 = mul(g_mProjection, float4(q0, 1)); - const float4 vP1 = mul(g_mProjection, float4(q1, 1)); - const float4 vP2 = mul(g_mProjection, float4(q2, 1)); - const float4 vP3 = mul(g_mProjection, float4(q3, 1)); +float4 IntersectEdgeAgainstPlane(ClipVertex v0, ClipVertex v1) +{ + float alpha = saturate(v0.bc * rcp(v0.bc - v1.bc)); // Guaranteed to lie between 0 and 1 + return lerp(v0.pt, v1.pt, alpha); +} - int iSrcIndex = 0; +void ClipPolygonAgainstPlane(uint p, uint srcBegin, uint srcSize, + inout float4 vertRingBuffer[MAX_CLIP_VERTS], + out uint dstBegin, out uint dstSize) +{ + dstBegin = srcBegin + srcSize; // Start at the end; we don't use modular arithmetic here + dstSize = 0; - int offs = iSrcIndex*MAX_PNTS+subLigt*MAX_PNTS*2; + ClipVertex tailVert = CreateClipVertex(p, vertRingBuffer[(srcBegin + srcSize - 1) % MAX_CLIP_VERTS]); - // fill up source clip buffer with the quad - posX[offs+0]=vP0.x; posX[offs+1]=vP1.x; posX[offs+2]=vP2.x; posX[offs+3]=vP3.x; - posY[offs+0]=vP0.y; posY[offs+1]=vP1.y; posY[offs+2]=vP2.y; posY[offs+3]=vP3.y; - posZ[offs+0]=vP0.z; posZ[offs+1]=vP1.z; posZ[offs+2]=vP2.z; posZ[offs+3]=vP3.z; - posW[offs+0]=vP0.w; posW[offs+1]=vP1.w; posW[offs+2]=vP2.w; posW[offs+3]=vP3.w; +#ifdef OBTUSE_COMPILER + uint modSrcIdx = srcBegin % MAX_CLIP_VERTS; + uint modDstIdx = dstBegin % MAX_CLIP_VERTS; +#endif - int iNrSrcVerts = 4; + for (uint j = srcBegin; j < (srcBegin + srcSize); j++) + { + #ifndef OBTUSE_COMPILER + uint modSrcIdx = j % MAX_CLIP_VERTS; + #endif + ClipVertex leadVert = CreateClipVertex(p, vertRingBuffer[modSrcIdx]); + + // Execute Blinn's line clipping algorithm. + // Classify the line segment. 4 cases: + // 0. v0 out, v1 out -> add nothing + // 1. v0 in, v1 out -> add intersection + // 2. v0 out, v1 in -> add intersection, add v1 + // 3. v0 in, v1 in -> add v1 + // (bc >= 0) <-> in, (bc < 0) <-> out. Beware of -0. + + if ((tailVert.bc >= 0) != (leadVert.bc >= 0)) + { + // The line segment is guaranteed to cross the plane. + float4 clipVert = IntersectEdgeAgainstPlane(tailVert, leadVert); + #ifndef OBTUSE_COMPILER + uint modDstIdx = (dstBegin + dstSize++) % MAX_CLIP_VERTS; + #endif + vertRingBuffer[modDstIdx] = clipVert; + #ifdef OBTUSE_COMPILER + dstSize++; + modDstIdx++; + modDstIdx = (modDstIdx == MAX_CLIP_VERTS) ? 0 : modDstIdx; + #endif + } - // do true clipping - for(int p=0; p<6; p++) - { - const int nrVertsDst = ClipAgainstPlane(iSrcIndex, iNrSrcVerts, subLigt, p); + if (leadVert.bc >= 0) + { + #ifndef OBTUSE_COMPILER + uint modDstIdx = (dstBegin + dstSize++) % MAX_CLIP_VERTS; + #endif + vertRingBuffer[modDstIdx] = leadVert.pt; + #ifdef OBTUSE_COMPILER + dstSize++; + modDstIdx++; + modDstIdx = (modDstIdx == MAX_CLIP_VERTS) ? 0 : modDstIdx; + #endif + } - iSrcIndex = 1-iSrcIndex; - iNrSrcVerts = nrVertsDst; + #ifdef OBTUSE_COMPILER + modSrcIdx++; + modSrcIdx = (modSrcIdx == MAX_CLIP_VERTS) ? 0 : modSrcIdx; + #endif + tailVert = leadVert; // Avoid recomputation and overwriting the vertex in the ring buffer + } +} - if(iNrSrcVerts<3 || iNrSrcVerts>=MAX_PNTS) break; - } +void ClipFaceAgainstViewVolume(uint f, uint behindMasksOfVerts[NUM_VERTS], uint baseVertexOffset, + out uint srcBegin, out uint srcSize, + out float4 vertRingBuffer[MAX_CLIP_VERTS]) +{ + srcBegin = 0; + srcSize = 4; - // final clipped convex primitive is in src buffer - if(iNrSrcVerts>2) - { - int offs_src = iSrcIndex*MAX_PNTS+subLigt*MAX_PNTS*2; - for(int k=0; kradius) - { - float2 vMi, vMa; - bool2 bMi, bMa; - CalcBound(bMi, bMa, vMi, vMa, g_mInvProjection, center, radius); + uint i; // Avoid multiply-declared variable warning - vMin.xy = bMi ? max(vMin.xy, vMi) : vMin.xy; - vMax.xy = bMa ? min(vMax.xy, vMa) : vMax.xy; - } - else if(g_isOrthographic!=0) - { - float2 vMi = mul(g_mProjection, float4(center.xyz-radius,1)).xy; // no division needed for ortho - float2 vMa = mul(g_mProjection, float4(center.xyz+radius,1)).xy; // no division needed for ortho - vMin.xy = max(vMin.xy, vMi); - vMax.xy = min(vMax.xy, vMa); - } -#ifndef USE_OBLIQUE_MODE -#if USE_LEFT_HAND_CAMERA_SPACE - if((center.z-radius)>0.0) - { - float4 vPosF = mul(g_mProjection, float4(0,0,center.z-radius,1)); - vMin.z = max(vMin.z, vPosF.z/vPosF.w); - } - if((center.z+radius)>0.0) - { - float4 vPosB = mul(g_mProjection, float4(0,0,center.z+radius,1)); - vMax.z = min(vMax.z, vPosB.z/vPosB.w); - } -#else - if((center.z+radius)<0.0) - { - float4 vPosF = mul(g_mProjection, float4(0,0,center.z+radius,1)); - vMin.z = max(vMin.z, vPosF.z/vPosF.w); - } - if((center.z-radius)<0.0) - { - float4 vPosB = mul(g_mProjection, float4(0,0,center.z-radius,1)); - vMax.z = min(vMax.z, vPosB.z/vPosB.w); - } -#endif - else - { - vMin = float3(-3,-3,-3); - vMax = float3(-2,-2,-2); - } -#endif - } + // (1) Compute the vertices of the light volume. + for (i = 0; i < VERTS_PER_THREAD; i++) + { + uint v = i * THREADS_PER_LIGHT + t % THREADS_PER_LIGHT; + + // rbpVerts[0] = rbpC - rbpX * scale - rbpY * scale - rbpZ; (-s, -s, -1) + // rbpVerts[1] = rbpC + rbpX * scale - rbpY * scale - rbpZ; (+s, -s, -1) + // rbpVerts[2] = rbpC - rbpX * scale + rbpY * scale - rbpZ; (-s, +s, -1) + // rbpVerts[3] = rbpC + rbpX * scale + rbpY * scale - rbpZ; (+s, +s, -1) + // rbpVerts[4] = rbpC - rbpX - rbpY + rbpZ; (-1, -1, +1) + // rbpVerts[5] = rbpC + rbpX - rbpY + rbpZ; (+1, -1, +1) + // rbpVerts[6] = rbpC - rbpX + rbpY + rbpZ; (-1, +1, +1) + // rbpVerts[7] = rbpC + rbpX + rbpY + rbpZ; (+1, +1, +1) + + float3 m = GenerateVertexOfStandardCube(v); + m.xy *= ((v & 4) == 0) ? scale : 1; // X, Y in [-scale, scale] + + float3 rbpVertVS = rbpC + m.x * rbpX + m.y * rbpY + m.z * rbpZ; + // Avoid generating (w = 0). + rbpVertVS.z = (abs(rbpVertVS.z) > FLT_MIN) ? rbpVertVS.z : FLT_MIN; + + float4 hapVert = mul(projMat, float4(rbpVertVS, 1)); + + // Warning: the W component may be negative. + // Flipping the -W pyramid by negating all coordinates is incorrect + // and will break both classification and clipping. + // For the orthographic projection, (w = 1). + + // Transform the X and Y components: [-w, w] -> [0, w]. + hapVert.xy = 0.5 * hapVert.xy + (0.5 * hapVert.w); + + // For each vertex, we must determine whether it is within the bounds. + // For culling and clipping, we must know, per culling plane, whether the vertex + // is in the positive or the negative half-space. + uint behindMask = 0; // Initially in front + + // Consider the vertex to be inside the view volume if: + // 0 <= x <= w + // 0 <= y <= w <-- include boundary points to avoid clipping them later + // 0 <= z <= w + // w is always valid + // TODO: epsilon for numerical robustness? + + for (uint j = 0; j < (NUM_PLANES / 2); j++) + { + float w = hapVert.w; + + behindMask |= (hapVert[j] < 0 ? 1 : 0) << (2 * j + 0); // Planes crossing '0' + behindMask |= (hapVert[j] > w ? 1 : 0) << (2 * j + 1); // Planes crossing 'w' + } + if (behindMask == 0) // Inside? + { + // Clamp to the bounds in case of numerical errors (may still generate -0). + float3 rapVertNDC = saturate(hapVert.xyz * rcp(hapVert.w)); - // we should consider doing a look-up here into a max depth mip chain - // to see if the light is occluded: vMin.z*VIEWPORT_SCALE_Z > MipTexelMaxDepth - //g_vBoundsBuffer[lgtIndex+0] = float3(0.5*vMin.x+0.5, -0.5*vMax.y+0.5, vMin.z*VIEWPORT_SCALE_Z); - //g_vBoundsBuffer[lgtIndex+g_iNrVisibLights] = float3(0.5*vMax.x+0.5, -0.5*vMin.y+0.5, vMax.z*VIEWPORT_SCALE_Z); + ndcAaBbMinPt = min(ndcAaBbMinPt, float4(rapVertNDC, rbpVertVS.z)); + ndcAaBbMaxPt = max(ndcAaBbMaxPt, float4(rapVertNDC, rbpVertVS.z)); + } + else // Outside + { + cullClipFaceMask |= GetFaceMaskOfVertex(v); + } - // changed for unity + gs_HapVertsX[baseVertexOffset + v] = hapVert.x; + gs_HapVertsY[baseVertexOffset + v] = hapVert.y; + gs_HapVertsZ[baseVertexOffset + v] = hapVert.z; + gs_HapVertsW[baseVertexOffset + v] = hapVert.w; + gs_BehindMasksOfVerts[baseVertexOffset + v] = behindMask; + } - // Each light's AABB is represented by two float3s, the min and max of the box. - // And for stereo, we have two sets of lights. Therefore, each eye has a set of mins, followed by - // a set of maxs, and each set is equal to g_iNrVisibLights. - const ScreenSpaceBoundsIndices boundsIndices = GenerateScreenSpaceBoundsIndices(lgtIndex, g_iNrVisibLights, eyeIndex); +#ifdef PLATFORM_SUPPORTS_WAVE_INTRINSICS + for (i = 0; i < FastLog2(THREADS_PER_LIGHT); i++) + { + uint andMask = PLATFORM_LANE_COUNT - 1; // All lanes + uint orMask = 0; // Plays no role + uint xorMask = 1 << i; // Flip bits one by one starting from the LSB - // build a linear (in camera space) min/max Z for the aabb. This is needed for clustered when oblique is active - float linMiZ, linMaZ; -#ifndef USE_OBLIQUE_MODE - float2 vMiZW = mul(g_mInvProjection, float4(vMin,1)).zw; - float2 vMaZW = mul(g_mInvProjection, float4(vMax,1)).zw; - linMiZ = vMiZW.x/vMiZW.y; linMaZ = vMaZW.x/vMaZW.y; + cullClipFaceMask |= LaneSwizzle(cullClipFaceMask, andMask, orMask, xorMask); + } #else - for(int i=0; i<8; i++) // establish 8 aabb points in camera space. - { - float3 vP = float3((i&1)!=0 ? vMax.x : vMin.x, (i&2)!=0 ? vMax.y : vMin.y, (i&4)!=0 ? vMax.z : vMin.z); + InterlockedOr(gs_CullClipFaceMasks[intraGroupLightIndex], cullClipFaceMask); - float2 v2Pc = mul(g_mInvProjection, float4(vP,1)).zw; - float linZ = v2Pc.x/v2Pc.y; + GroupMemoryBarrierWithGroupSync(); - if(i==0) { linMiZ=linZ; linMaZ=linZ; } -#if USE_LEFT_HAND_CAMERA_SPACE - linMiZ = min(linMiZ, linZ); linMaZ = max(linMaZ, linZ); -#else - linMiZ = max(linMiZ, linZ); linMaZ = min(linMaZ, linZ); + cullClipFaceMask = gs_CullClipFaceMasks[intraGroupLightIndex]; #endif - } - float z0 = center.z-radius, z1 = center.z+radius; -#if USE_LEFT_HAND_CAMERA_SPACE - linMiZ = max(linMiZ, z0); linMaZ = min(linMaZ, z1); -#else - linMiZ = min(linMiZ, z1); linMaZ = max(linMaZ, z0); -#endif + // (2) Test the corners of the view volume. + if (cullClipFaceMask != 0) + { + // The light is partially outside the view volume. + // Therefore, some of the corners of the view volume may be inside the light volume. + // We perform aggressive culling, so we must make sure they are accounted for. + // The light volume is a special type of cuboid - a right frustum. + // We can exploit this fact by building a light-space projection matrix. + float4x4 invTranslateToLightSpace = Translation4x4(-rbpC); + float4x4 invRotateAndScaleInLightSpace = Homogenize3x3(Invert3x3(ScaledRotation3x3(rbpX, rbpY, rbpZ))); + // TODO: avoid full inversion by using unit vectors and passing magnitudes explicitly. + + // This (orthographic) projection matrix maps a view-space point to a light-space [-1, 1]^3 cube. + float4x4 lightSpaceMatrix = mul(invRotateAndScaleInLightSpace, invTranslateToLightSpace); + + if (scale != 1) // Perspective light space? + { + // Compute the parameters of the perspective projection. + float s = scale; + float e = -1 - 2 * (s * rcp(1 - s)); // Signed distance from the origin to the eye + float n = -e - 1; // Distance from the eye to the near plane + float f = -e + 1; // Distance from the eye to the far plane + float g = f; // Distance from the eye to the projection plane -#endif + float4x4 invTranslateEye = Translation4x4(float3(0, 0, -e)); + float4x4 perspProjMatrix = PerspectiveProjection4x4(1, g, n, f); - g_vBoundsBuffer[boundsIndices.min] = float4(0.5*vMin.x + 0.5, 0.5*vMin.y + 0.5, vMin.z*VIEWPORT_SCALE_Z, linMiZ); - g_vBoundsBuffer[boundsIndices.max] = float4(0.5*vMax.x + 0.5, 0.5*vMax.y + 0.5, vMax.z*VIEWPORT_SCALE_Z, linMaZ); + lightSpaceMatrix = mul(mul(perspProjMatrix, invTranslateEye), lightSpaceMatrix); } - } -} + for (i = 0; i < VERTS_PER_THREAD; i++) + { + uint v = i * THREADS_PER_LIGHT + t % THREADS_PER_LIGHT; -float4 GenNewVert(const float4 vVisib, const float4 vInvisib, const int p); + float3 rapVertCS = GenerateVertexOfStandardCube(v); + rapVertCS.z = rapVertCS.z * 0.5 + 0.5; // View's projection matrix MUST map Z to [0, 1] -int ClipAgainstPlane(const int iSrcIndex, const int iNrSrcVerts, const int subLigt, const int p) -{ - int offs_src = iSrcIndex*MAX_PNTS+subLigt*MAX_PNTS*2; - int offs_dst = (1-iSrcIndex)*MAX_PNTS+subLigt*MAX_PNTS*2; + float4 hbpVertVS = mul(invProjMat, float4(rapVertCS, 1)); // Clip to view space + float4 hapVertLS = mul(lightSpaceMatrix, hbpVertVS); // View to light space - float4 vPrev = float4(posX[offs_src+(iNrSrcVerts-1)], posY[offs_src+(iNrSrcVerts-1)], posZ[offs_src+(iNrSrcVerts-1)], posW[offs_src+(iNrSrcVerts-1)]); + // Consider the vertex to be inside the light volume if: + // -w < x < w + // -w < y < w <-- exclude boundary points, as we will not clip using these vertices + // -w < z < w <-- assume that Z-precision is not very important here + // 0 < w + // TODO: epsilon for numerical robustness? - int nrVertsDst = 0; + bool inside = Max3(abs(hapVertLS.x), abs(hapVertLS.y), abs(hapVertLS.z)) < hapVertLS.w; - unsigned int uMask = (1<P.w)?2:0) | ((P.y<-P.w)?4:0) | ((P.y>P.w)?8:0) | ((P.z<0)?16:0) | ((P.z>P.w)?32:0)) & (bIsObliqueClipPlane ? 0x1f : 0x3f); -} - -float4 GenNewVert(const float4 vVisib, const float4 vInvisib, const int p) -{ - const float fS = p==4 ? 0 : ((p&1)==0 ? -1 : 1); - const int index = ((uint) p)/2; - float x1 = index==0 ? vVisib.x : (index==1 ? vVisib.y : vVisib.z); - float x0 = index==0 ? vInvisib.x : (index==1 ? vInvisib.y : vInvisib.z); - - //fS*((vVisib.w-vInvisib.w)*t + vInvisib.w) = (x1-x0)*t + x0; - - const float fT = (fS*vInvisib.w-x0)/((x1-x0) - fS*(vVisib.w-vInvisib.w)); - float4 vNew = vVisib*fT + vInvisib*(1-fT); - - // just to be really anal we make sure the clipped against coordinate is precise - if(index==0) vNew.x = fS*vNew.w; - else if(index==1) vNew.y = fS*vNew.w; - else vNew.z = fS*vNew.w; - - return vNew; -} + uint behindMasksOfVerts[NUM_VERTS]; + for (i = 0; i < NUM_VERTS; i++) + { + behindMasksOfVerts[i] = gs_BehindMasksOfVerts[baseVertexOffset + i]; + } -float4 TransformPlaneToPostSpace(float4x4 InvProjection, float4 plane) -{ - return mul(plane, InvProjection); -} + // (3) Cull the faces. + { + const uint cullFaceMask = cullClipFaceMask; + const uint numFacesToCull = countbits(cullFaceMask); // [0, 6] -float4 EvalPlanePair(out bool validPlanes, float2 posXY_in, float r) -{ - // rotate by 90 degrees to avoid potential division by zero - bool bMustFlip = abs(posXY_in.y)0.0; + cullClipFaceMask &= LaneSwizzle(cullClipFaceMask, andMask, orMask, xorMask); + } +#else + InterlockedAnd(gs_CullClipFaceMasks[intraGroupLightIndex], cullClipFaceMask); - return res; -} + GroupMemoryBarrierWithGroupSync(); -void CalcBound(out bool2 bIsMinValid, out bool2 bIsMaxValid, out float2 vMin, out float2 vMax, float4x4 InvProjection, float3 pos_view_space, float r) -{ - bool validX, validY; - float4 planeX = EvalPlanePair(validX, float2(pos_view_space.x, pos_view_space.z), r); - float4 planeY = EvalPlanePair(validY, float2(pos_view_space.y, pos_view_space.z), r); + cullClipFaceMask = gs_CullClipFaceMasks[intraGroupLightIndex]; +#endif + // (4) Clip the faces. + { + const uint clipFaceMask = cullClipFaceMask; + const uint numFacesToClip = countbits(clipFaceMask); // [0, 6] -#if USE_LEFT_HAND_CAMERA_SPACE - planeX = planeX.zwxy; // need to swap left/right and top/bottom planes when using left hand system - planeY = planeY.zwxy; -#endif + for (i = 0; i < FACES_PER_THREAD; i++) + { + uint n = i * THREADS_PER_LIGHT + t % THREADS_PER_LIGHT; - bIsMinValid = bool2(planeX.z<0, planeY.z<0) && bool2(validX,validY); - bIsMaxValid = bool2((-planeX.x)<0, (-planeY.x)<0) && bool2(validX,validY); + if (n < numFacesToClip) + { + uint f = NthBitLow(clipFaceMask, n); + + uint srcBegin, srcSize; + float4 vertRingBuffer[MAX_CLIP_VERTS]; + ClipFaceAgainstViewVolume(f, behindMasksOfVerts, baseVertexOffset, + srcBegin, srcSize, vertRingBuffer); + UpdateAaBb(srcBegin, srcSize, vertRingBuffer, g_isOrthographic != 0, invProjMat, + ndcAaBbMinPt, ndcAaBbMaxPt); + } + } + } - // hopefully the compiler takes zeros into account - // should be the case since the transformation in TransformPlaneToPostSpace() - // is done using multiply-adds and not dot product instructions. - float4 planeX0 = TransformPlaneToPostSpace(InvProjection, float4(planeX.x, 0, planeX.y, 0)); - float4 planeX1 = TransformPlaneToPostSpace(InvProjection, float4(planeX.z, 0, planeX.w, 0)); - float4 planeY0 = TransformPlaneToPostSpace(InvProjection, float4(0, planeY.x, planeY.y, 0)); - float4 planeY1 = TransformPlaneToPostSpace(InvProjection, float4(0, planeY.z, planeY.w, 0)); +#ifdef PLATFORM_SUPPORTS_WAVE_INTRINSICS + for (i = 0; i < FastLog2(THREADS_PER_LIGHT); i++) + { + uint andMask = PLATFORM_LANE_COUNT - 1; // All lanes + uint orMask = 0; // Plays no role + uint xorMask = 1 << i; // Flip bits one by one starting from the LSB + + ndcAaBbMinPt.x = min(ndcAaBbMinPt.x, LaneSwizzle(ndcAaBbMinPt.x, andMask, orMask, xorMask)); + ndcAaBbMaxPt.x = max(ndcAaBbMaxPt.x, LaneSwizzle(ndcAaBbMaxPt.x, andMask, orMask, xorMask)); + ndcAaBbMinPt.y = min(ndcAaBbMinPt.y, LaneSwizzle(ndcAaBbMinPt.y, andMask, orMask, xorMask)); + ndcAaBbMaxPt.y = max(ndcAaBbMaxPt.y, LaneSwizzle(ndcAaBbMaxPt.y, andMask, orMask, xorMask)); + ndcAaBbMinPt.z = min(ndcAaBbMinPt.z, LaneSwizzle(ndcAaBbMinPt.z, andMask, orMask, xorMask)); + ndcAaBbMaxPt.z = max(ndcAaBbMaxPt.z, LaneSwizzle(ndcAaBbMaxPt.z, andMask, orMask, xorMask)); + ndcAaBbMinPt.w = min(ndcAaBbMinPt.w, LaneSwizzle(ndcAaBbMinPt.w, andMask, orMask, xorMask)); + ndcAaBbMaxPt.w = max(ndcAaBbMaxPt.w, LaneSwizzle(ndcAaBbMaxPt.w, andMask, orMask, xorMask)); + } +#else + // Integer comparison works for floating-point numbers as long as the sign bit is 0. + // We must take care of -0 ourselves. saturate() does not help. + InterlockedMin(gs_NdcAaBbMinPtX[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMinPt.x))); + InterlockedMax(gs_NdcAaBbMaxPtX[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMaxPt.x))); + InterlockedMin(gs_NdcAaBbMinPtY[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMinPt.y))); + InterlockedMax(gs_NdcAaBbMaxPtY[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMaxPt.y))); + InterlockedMin(gs_NdcAaBbMinPtZ[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMinPt.z))); + InterlockedMax(gs_NdcAaBbMaxPtZ[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMaxPt.z))); + InterlockedMin(gs_NdcAaBbMinPtW[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMinPt.w))); + InterlockedMax(gs_NdcAaBbMaxPtW[intraGroupLightIndex], asuint(CLEAR_SIGN_BIT(ndcAaBbMaxPt.w))); + GroupMemoryBarrierWithGroupSync(); - // convert planes to the forms (1,0,0,D) and (0,1,0,D) - // 2D bound is given by -D components - float2 A = -float2(planeX0.w / planeX0.x, planeY0.w / planeY0.y); - float2 B = -float2(planeX1.w / planeX1.x, planeY1.w / planeY1.y); + ndcAaBbMinPt.x = asfloat(gs_NdcAaBbMinPtX[intraGroupLightIndex]); + ndcAaBbMaxPt.x = asfloat(gs_NdcAaBbMaxPtX[intraGroupLightIndex]); + ndcAaBbMinPt.y = asfloat(gs_NdcAaBbMinPtY[intraGroupLightIndex]); + ndcAaBbMaxPt.y = asfloat(gs_NdcAaBbMaxPtY[intraGroupLightIndex]); + ndcAaBbMinPt.z = asfloat(gs_NdcAaBbMinPtZ[intraGroupLightIndex]); + ndcAaBbMaxPt.z = asfloat(gs_NdcAaBbMaxPtZ[intraGroupLightIndex]); + ndcAaBbMinPt.w = asfloat(gs_NdcAaBbMinPtW[intraGroupLightIndex]); + ndcAaBbMaxPt.w = asfloat(gs_NdcAaBbMaxPtW[intraGroupLightIndex]); +#endif // PLATFORM_SUPPORTS_WAVE_INTRINSICS + + if ((globalLightIndex < (uint)g_iNrVisibLights) && (t % THREADS_PER_LIGHT == 0)) // Avoid bank conflicts + { + // For stereo, we have two sets of lights. Therefore, each eye has a set of mins + // followed by a set of maxs, and each set is equal to g_iNrVisibLights. + const ScreenSpaceBoundsIndices eyeAdjustedOutputOffsets = GenerateScreenSpaceBoundsIndices(globalLightIndex, g_iNrVisibLights, eyeIndex); - // Bound is complete - vMin = B; - vMax = A; + g_vBoundsBuffer[eyeAdjustedOutputOffsets.min] = ndcAaBbMinPt; + g_vBoundsBuffer[eyeAdjustedOutputOffsets.max] = ndcAaBbMaxPt; + } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs index be2a0d56818..303d15f1e2e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs @@ -239,9 +239,9 @@ internal void CreateProbeVolumeBuffers() s_ProbeVolumeAtlasBlitDataSHL2Buffer = new ComputeBuffer(s_MaxProbeVolumeProbeCount * ProbeVolumePayload.GetDataSHL2Stride(), Marshal.SizeOf(typeof(float))); } s_ProbeVolumeAtlasBlitDataValidityBuffer = new ComputeBuffer(s_MaxProbeVolumeProbeCount, Marshal.SizeOf(typeof(float))); - + m_ProbeVolumeAtlasSHRTDepthSliceCount = GetDepthSliceCountFromEncodingMode(ShaderConfig.s_ProbeVolumesEncodingMode); - + m_ProbeVolumeAtlasSHRTHandle = RTHandles.Alloc( width: s_ProbeVolumeAtlasResolution, height: s_ProbeVolumeAtlasResolution, @@ -258,7 +258,7 @@ internal void CreateProbeVolumeBuffers() if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode == ProbeVolumesBilateralFilteringModes.OctahedralDepth) { s_ProbeVolumeAtlasOctahedralDepthBuffer = new ComputeBuffer(s_MaxProbeVolumeProbeOctahedralDepthCount, Marshal.SizeOf(typeof(float))); - + // TODO: (Nick): Might be able drop precision down to half-floats, since we only need to encode depth data up to one probe spacing distance away. Could rescale depth data to this range before encoding. m_ProbeVolumeAtlasOctahedralDepthRTHandle = RTHandles.Alloc( width: s_ProbeVolumeAtlasOctahedralDepthResolution, @@ -383,7 +383,7 @@ unsafe void UpdateShaderVariablesGlobalProbeVolumes(ref ShaderVariablesGlobal cb { cb._ProbeVolumeAtlasOctahedralDepthResolutionAndInverse = Vector4.zero; } - + var settings = hdCamera.volumeStack.GetComponent(); LeakMitigationMode leakMitigationMode = (settings == null) @@ -531,7 +531,7 @@ internal bool EnsureProbeVolumeInAtlas(ScriptableRenderContext renderContext, Co 1.0f / (float)s_ProbeVolumeAtlasResolution, 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount )); - + s_ProbeVolumeAtlasBlitDataSHL01Buffer.SetData(payload.dataSHL01); s_ProbeVolumeAtlasBlitDataValidityBuffer.SetData(payload.dataValidity); cmd.SetComputeIntParam(s_ProbeVolumeAtlasBlitCS, HDShaderIDs._ProbeVolumeAtlasReadBufferCount, size); @@ -630,7 +630,7 @@ internal bool EnsureProbeVolumeInAtlasOctahedralDepth(ScriptableRenderContext re 1.0f / (float)s_ProbeVolumeAtlasResolution, 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount )); - + s_ProbeVolumeAtlasOctahedralDepthBuffer.SetData(payload.dataOctahedralDepth); cmd.SetComputeIntParam(s_ProbeVolumeAtlasOctahedralDepthBlitCS, HDShaderIDs._ProbeVolumeAtlasOctahedralDepthReadBufferCount, size); @@ -911,21 +911,53 @@ internal static uint PackProbeVolumeSortKey(VolumeBlendMode volumeBlendMode, flo return blendModeBits | logVolumeBits | indexBits; } - void DisplayProbeVolumeAtlas(CommandBuffer cmd, Material debugMaterial, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, int sliceMode) + void RenderProbeVolumeDebugOverlay(in DebugParameters debugParameters, CommandBuffer cmd) { - if (ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.Disabled) - return; - if (!m_SupportProbeVolume) return; - Vector4 validRange = new Vector4(minValue, 1.0f / (maxValue - minValue)); - Vector3 textureViewScale = new Vector3(1.0f, 1.0f, 1.0f); - Vector3 textureViewBias = new Vector3(0.0f, 0.0f, 0.0f); - Vector3 textureViewResolution = new Vector3(s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution); - Vector4 atlasTextureOctahedralDepthScaleBias = new Vector4(1.0f, 1.0f, 0.0f, 0.0f); + LightingDebugSettings lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; + if (lightingDebug.probeVolumeDebugMode != ProbeVolumeDebugMode.None) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ProbeVolumeDebug))) + { + if (lightingDebug.probeVolumeDebugMode == ProbeVolumeDebugMode.VisualizeAtlas) + { + DisplayProbeVolumeAtlas(cmd, debugParameters.probeVolumeOverlayParameters, debugParameters.debugOverlay); + } + } + } + } - #if UNITY_EDITOR + struct ProbeVolumeDebugOverlayParameters + { + public Material material; + public Vector4 validRange; + public Vector4 textureViewScale; + public Vector4 textureViewBias; + public Vector3 textureViewResolution; + public Vector4 atlasResolutionAndSliceCount; + public Vector4 atlasResolutionAndSliceCountInverse; + public Vector4 atlasTextureOctahedralDepthScaleBias; + public int sliceMode; + public RTHandle probeVolumeAtlas; + public RTHandle probeVolumeAtlasOctahedralDepth; + } + + ProbeVolumeDebugOverlayParameters PrepareProbeVolumeOverlayParameters(LightingDebugSettings lightingDebug) + { + ProbeVolumeDebugOverlayParameters parameters = new ProbeVolumeDebugOverlayParameters(); + + parameters.material = m_DebugDisplayProbeVolumeMaterial; + + parameters.sliceMode = (int)lightingDebug.probeVolumeAtlasSliceMode; + parameters.validRange = new Vector4(lightingDebug.probeVolumeMinValue, 1.0f / (lightingDebug.probeVolumeMaxValue - lightingDebug.probeVolumeMinValue)); + parameters.textureViewScale = new Vector3(1.0f, 1.0f, 1.0f); + parameters.textureViewBias = new Vector3(0.0f, 0.0f, 0.0f); + parameters.textureViewResolution = new Vector3(s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution); + parameters.atlasTextureOctahedralDepthScaleBias = new Vector4(1.0f, 1.0f, 0.0f, 0.0f); + +#if UNITY_EDITOR if (UnityEditor.Selection.activeGameObject != null) { var selectedProbeVolume = UnityEditor.Selection.activeGameObject.GetComponent(); @@ -936,9 +968,9 @@ void DisplayProbeVolumeAtlas(CommandBuffer cmd, Material debugMaterial, float sc int selectedProbeVolumeKey = selectedProbeVolume.GetID(); if (probeVolumeAtlas.TryGetScaleBias(out Vector3 selectedProbeVolumeScale, out Vector3 selectedProbeVolumeBias, selectedProbeVolumeKey)) { - textureViewScale = selectedProbeVolumeScale; - textureViewBias = selectedProbeVolumeBias; - textureViewResolution = new Vector3( + parameters.textureViewScale = selectedProbeVolumeScale; + parameters.textureViewBias = selectedProbeVolumeBias; + parameters.textureViewResolution = new Vector3( selectedProbeVolume.parameters.resolutionX, selectedProbeVolume.parameters.resolutionY, selectedProbeVolume.parameters.resolutionZ @@ -949,46 +981,50 @@ void DisplayProbeVolumeAtlas(CommandBuffer cmd, Material debugMaterial, float sc { if (probeVolumeAtlasOctahedralDepth.TryGetScaleBias(out Vector4 selectedProbeVolumeOctahedralDepthScaleBias, selectedProbeVolumeKey)) { - atlasTextureOctahedralDepthScaleBias = selectedProbeVolumeOctahedralDepthScaleBias; + parameters.atlasTextureOctahedralDepthScaleBias = selectedProbeVolumeOctahedralDepthScaleBias; } } } } - #endif +#endif // Note: The system is not aware of slice packing in Z. // Need to modify scale and bias terms just before uploading to GPU. // TODO: Should we make it aware earlier up the chain? - textureViewScale.z = textureViewScale.z / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount; - textureViewBias.z = textureViewBias.z / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount; + parameters.textureViewScale.z = parameters.textureViewScale.z / m_ProbeVolumeAtlasSHRTDepthSliceCount; + parameters.textureViewBias.z = parameters.textureViewBias.z / m_ProbeVolumeAtlasSHRTDepthSliceCount; + + parameters.atlasResolutionAndSliceCount = new Vector4(s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution, s_ProbeVolumeAtlasResolution, m_ProbeVolumeAtlasSHRTDepthSliceCount); + parameters.atlasResolutionAndSliceCountInverse = new Vector4(1.0f / s_ProbeVolumeAtlasResolution, 1.0f / s_ProbeVolumeAtlasResolution, 1.0f / s_ProbeVolumeAtlasResolution, 1.0f / m_ProbeVolumeAtlasSHRTDepthSliceCount); + + parameters.probeVolumeAtlas = m_ProbeVolumeAtlasSHRTHandle; + parameters.probeVolumeAtlasOctahedralDepth = m_ProbeVolumeAtlasOctahedralDepthRTHandle; + + return parameters; + } + static void DisplayProbeVolumeAtlas(CommandBuffer cmd, in ProbeVolumeDebugOverlayParameters parameters, DebugOverlay debugOverlay) + { MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); - propertyBlock.SetTexture(HDShaderIDs._AtlasTextureSH, m_ProbeVolumeAtlasSHRTHandle.rt); - propertyBlock.SetVector(HDShaderIDs._TextureViewScale, textureViewScale); - propertyBlock.SetVector(HDShaderIDs._TextureViewBias, textureViewBias); - propertyBlock.SetVector(HDShaderIDs._TextureViewResolution, textureViewResolution); - cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCount, new Vector4( - s_ProbeVolumeAtlasResolution, - s_ProbeVolumeAtlasResolution, - s_ProbeVolumeAtlasResolution, - m_ProbeVolumeAtlasSHRTDepthSliceCount - )); - cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCountInverse, new Vector4( - 1.0f / (float)s_ProbeVolumeAtlasResolution, - 1.0f / (float)s_ProbeVolumeAtlasResolution, - 1.0f / (float)s_ProbeVolumeAtlasResolution, - 1.0f / (float)m_ProbeVolumeAtlasSHRTDepthSliceCount - )); + propertyBlock.SetTexture(HDShaderIDs._AtlasTextureSH, parameters.probeVolumeAtlas); + propertyBlock.SetVector(HDShaderIDs._TextureViewScale, parameters.textureViewScale); + propertyBlock.SetVector(HDShaderIDs._TextureViewBias, parameters.textureViewBias); + propertyBlock.SetVector(HDShaderIDs._TextureViewResolution, parameters.textureViewResolution); + cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCount, parameters.atlasResolutionAndSliceCount); + cmd.SetGlobalVector(HDShaderIDs._ProbeVolumeAtlasResolutionAndSliceCountInverse, parameters.atlasResolutionAndSliceCountInverse); if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode == ProbeVolumesBilateralFilteringModes.OctahedralDepth) { - propertyBlock.SetTexture(HDShaderIDs._AtlasTextureOctahedralDepth, m_ProbeVolumeAtlasOctahedralDepthRTHandle); - propertyBlock.SetVector(HDShaderIDs._AtlasTextureOctahedralDepthScaleBias, atlasTextureOctahedralDepthScaleBias); + propertyBlock.SetTexture(HDShaderIDs._AtlasTextureOctahedralDepth, parameters.probeVolumeAtlasOctahedralDepth); + propertyBlock.SetVector(HDShaderIDs._AtlasTextureOctahedralDepthScaleBias, parameters.atlasTextureOctahedralDepthScaleBias); } - propertyBlock.SetVector(HDShaderIDs._ValidRange, validRange); - propertyBlock.SetInt(HDShaderIDs._ProbeVolumeAtlasSliceMode, sliceMode); - cmd.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY)); - cmd.DrawProcedural(Matrix4x4.identity, debugMaterial, debugMaterial.FindPass("ProbeVolume"), MeshTopology.Triangles, 3, 1, propertyBlock); + + propertyBlock.SetVector(HDShaderIDs._ValidRange, parameters.validRange); + propertyBlock.SetInt(HDShaderIDs._ProbeVolumeAtlasSliceMode, parameters.sliceMode); + + debugOverlay.SetViewport(cmd); + cmd.DrawProcedural(Matrix4x4.identity, parameters.material, parameters.material.FindPass("ProbeVolume"), MeshTopology.Triangles, 3, 1, propertyBlock); + debugOverlay.Next(); } } // class ProbeVolumeLighting diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs index a730766918c..03e3ed1f536 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs @@ -21,8 +21,14 @@ public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureH { using (new RenderGraphProfilingScope(renderGraph, ProfilingSampler.Get(HDProfileId.AmbientOcclusion))) { - // Size must be checked independently of what version should be used - EnsureRTSize(settings, hdCamera); + float scaleFactor = m_RunningFullRes ? 1.0f : 0.5f; + if (settings.fullResolution != m_RunningFullRes) + { + m_RunningFullRes = settings.fullResolution; + scaleFactor = m_RunningFullRes ? 1.0f : 0.5f; + } + + hdCamera.AllocateAmbientOcclusionHistoryBuffer(scaleFactor); if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value) return m_RaytracingAmbientOcclusion.RenderRTAO(renderGraph, hdCamera, depthPyramid, normalBuffer, motionVectors, rayCountTexture, frameCount, shaderVariablesRaytracing); @@ -68,7 +74,7 @@ TextureHandle RenderAO(RenderGraph renderGraph, in RenderAOParameters parameters passData.parameters = parameters; passData.packedData = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one * scaleFactor, true, true) - { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, name = "AO Packed data" })); + { colorFormat = GraphicsFormat.R32_SFloat, enableRandomWrite = true, name = "AO Packed data" })); passData.depthPyramid = builder.ReadTexture(depthPyramid); passData.normalBuffer = builder.ReadTexture(normalBuffer); @@ -119,13 +125,12 @@ TextureHandle DenoiseAO( RenderGraph renderGraph, } passData.packedDataBlurred = builder.CreateTransientTexture( - new TextureDesc(Vector2.one * scaleFactor, true, true) { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, name = "AO Packed blurred data" }); + new TextureDesc(Vector2.one * scaleFactor, true, true) { colorFormat = GraphicsFormat.R32_SFloat, enableRandomWrite = true, name = "AO Packed blurred data" }); - var format = parameters.fullResolution ? GraphicsFormat.R8_UNorm : GraphicsFormat.R32_UInt; if (parameters.fullResolution) passData.denoiseOutput = builder.WriteTexture(CreateAmbientOcclusionTexture(renderGraph)); else - passData.denoiseOutput = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one * 0.5f, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R32_UInt, name = "Final Half Res AO Packed" })); + passData.denoiseOutput = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one * 0.5f, true, true) { enableRandomWrite = true, colorFormat = GraphicsFormat.R32_SFloat, name = "Final Half Res AO Packed" })); denoiseOutput = passData.denoiseOutput; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs index 18d9e6b437f..1a8f52fb4c1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs @@ -211,7 +211,7 @@ public int directionCount // RTAO [SerializeField, FormerlySerializedAs("rayLength")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(0.5f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("sampleCount")] private ClampedIntParameter m_SampleCount = new ClampedIntParameter(1, 1, 64); [SerializeField, FormerlySerializedAs("denoise")] @@ -274,29 +274,27 @@ internal AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset, RenderPipelineRes if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) return; - - AllocRT(0.5f); - } - - internal void Cleanup() - { - if (HDRenderPipeline.GatherRayTracingSupport(m_Settings)) - { - m_RaytracingAmbientOcclusion.Release(); - } - - ReleaseRT(); } internal void InitializeNonRenderGraphResources() { float scaleFactor = m_RunningFullRes ? 1.0f : 0.5f; AllocRT(scaleFactor); + + if (HDRenderPipeline.GatherRayTracingSupport(m_Settings)) + { + m_RaytracingAmbientOcclusion.InitializeNonRenderGraphResources(); + } } internal void CleanupNonRenderGraphResources() { ReleaseRT(); + + if (HDRenderPipeline.GatherRayTracingSupport(m_Settings)) + { + m_RaytracingAmbientOcclusion.CleanupNonRenderGraphResources(); + } } internal void InitRaytracing(HDRenderPipeline renderPipeline) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs index 010c3ba9fc2..174c86780e0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs @@ -33,12 +33,6 @@ void InitScreenSpaceGlobalIllumination() { if (m_Asset.currentPlatformRenderPipelineSettings.supportSSGI) { - m_IndirectDiffuseBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer0"); - m_IndirectDiffuseBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer1"); - m_IndirectDiffuseBuffer2 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer2"); - m_IndirectDiffuseBuffer3 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer3"); - m_IndirectDiffuseHitPointBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseHitBuffer"); - // Grab the sets of shaders that we'll be using ComputeShader ssGICS = m_Asset.renderPipelineResources.shaders.screenSpaceGlobalIlluminationCS; ComputeShader bilateralUpsampleCS = m_Asset.renderPipelineResources.shaders.bilateralUpsampleCS; @@ -54,20 +48,6 @@ void InitScreenSpaceGlobalIllumination() } } - void ReleaseScreenSpaceGlobalIllumination() - { - if (m_IndirectDiffuseBuffer0 != null) - RTHandles.Release(m_IndirectDiffuseBuffer0); - if (m_IndirectDiffuseBuffer1 != null) - RTHandles.Release(m_IndirectDiffuseBuffer1); - if (m_IndirectDiffuseBuffer2 != null) - RTHandles.Release(m_IndirectDiffuseBuffer2); - if (m_IndirectDiffuseBuffer3 != null) - RTHandles.Release(m_IndirectDiffuseBuffer3); - if (m_IndirectDiffuseHitPointBuffer != null) - RTHandles.Release(m_IndirectDiffuseHitPointBuffer); - } - // This is shared between SSGI and RTGI IndirectDiffuseMode GetIndirectDiffuseMode(HDCamera hdCamera) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs index eebc3628114..9689447edd5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs @@ -213,8 +213,7 @@ public int rayMaxIterations private IntParameter m_RayMaxIterations = new IntParameter(32); [SerializeField, FormerlySerializedAs("rayLength")] - [Tooltip("Controls the length of reflection rays.")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(50.0f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("clampValue")] [Tooltip("Controls the clamp of intensity.")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs index ed6fb36a32a..e3c863eee3e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs @@ -58,8 +58,6 @@ public virtual void InitAtlas(RenderPipelineResources renderPipelineResources, i m_ClearMaterial = clearMaterial; m_BlurAlgorithm = blurAlgorithm; m_RenderPipelineResources = renderPipelineResources; - - AllocateRenderTexture(); } public HDShadowAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, BlurAlgorithm blurAlgorithm = BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.RenderGraph.cs index 3987edec624..aa6c660d313 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.RenderGraph.cs @@ -156,9 +156,9 @@ TextureHandle RenderScreenSpaceShadows(RenderGraph renderGraph, HDCamera hdCamer RenderLightScreenSpaceShadows(renderGraph, hdCamera, prepassOutput, depthBuffer, normalBuffer, motionVectorsBuffer, rayCountTexture, screenSpaceShadowTexture); } - // We render the debug view - // TODO: The texture is currently unused, make usage of it - EvaluateShadowDebugView(renderGraph, hdCamera, screenSpaceShadowTexture); + // We render the debug view, if the texture is not used, it is not evaluated anyway + TextureHandle screenSpaceShadowDebug = EvaluateShadowDebugView(renderGraph, hdCamera, screenSpaceShadowTexture); + PushFullScreenDebugTexture(m_RenderGraph, screenSpaceShadowDebug, FullScreenDebugMode.ScreenSpaceShadows); return screenSpaceShadowTexture; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs index 0560a8a7ae3..c2f199e17d5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs @@ -238,18 +238,26 @@ void InitializeScreenSpaceShadows() default: s_ScreenSpaceShadowsMat.EnableKeyword("SHADOW_MEDIUM"); break; - } + } + } + void ScreenSpaceShadowInitializeNonRenderGraphResources() + { // Allocate the final result texture int numShadowTextures = Math.Max((int)Math.Ceiling(m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.maxScreenSpaceShadowSlots / 4.0f), 1); GraphicsFormat graphicsFormat = (GraphicsFormat)m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.screenSpaceShadowBufferFormat; - m_ScreenSpaceShadowTextureArray = RTHandles.Alloc(Vector2.one, slices: numShadowTextures * TextureXR.slices, dimension:TextureDimension.Tex2DArray, filterMode: FilterMode.Point, colorFormat: graphicsFormat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "AreaShadowArrayBuffer"); + m_ScreenSpaceShadowTextureArray = RTHandles.Alloc(Vector2.one, slices: numShadowTextures * TextureXR.slices, dimension: TextureDimension.Tex2DArray, filterMode: FilterMode.Point, colorFormat: graphicsFormat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "AreaShadowArrayBuffer"); + } + + void ScreenSpaceShadowCleanupNonRenderGraphResources() + { + RTHandles.Release(m_ScreenSpaceShadowTextureArray); + m_ScreenSpaceShadowTextureArray = null; } void ReleaseScreenSpaceShadows() { CoreUtils.Destroy(s_ScreenSpaceShadowsMat); - RTHandles.Release(m_ScreenSpaceShadowTextureArray); } void BindBlackShadowTexture(CommandBuffer cmd) @@ -286,7 +294,6 @@ void RenderScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd) } } - bool RenderLightScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RaytracingLightShadow))) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs index 4bf4697e72c..c06a41d12cf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs @@ -17,6 +17,7 @@ struct RTShadowDirectionalTraceParameters public bool softShadow; public int numShadowSamples; public bool colorShadow; + public float maxShadowLength; // Kernels public int clearShadowKernel; @@ -33,6 +34,7 @@ struct RTShadowDirectionalTraceParameters RTShadowDirectionalTraceParameters PrepareRTShadowDirectionalTraceParameters(HDCamera hdCamera, HDAdditionalLightData additionalLightData) { RTShadowDirectionalTraceParameters rtsdtParams = new RTShadowDirectionalTraceParameters(); + RayTracingSettings rayTracingSettings = hdCamera.volumeStack.GetComponent(); // Set the camera parameters rtsdtParams.texWidth = hdCamera.actualWidth; @@ -44,6 +46,7 @@ RTShadowDirectionalTraceParameters PrepareRTShadowDirectionalTraceParameters(HDC // If the surface is infinitively small, we force it to one sample. rtsdtParams.numShadowSamples = rtsdtParams.softShadow ? additionalLightData.numRayTracingSamples : 1; rtsdtParams.colorShadow = m_CurrentSunLightAdditionalLightData.colorShadow; + rtsdtParams.maxShadowLength = rayTracingSettings.directionalShadowRayLength.value; // Kernels rtsdtParams.clearShadowKernel = m_ClearShadowTexture; @@ -151,6 +154,9 @@ static void ExecuteSSSDirectionalTrace(CommandBuffer cmd, RTShadowDirectionalTra // Define the shader pass to use for the shadow pass cmd.SetRayTracingShaderPass(rtsdtParams.screenSpaceShadowRT, "VisibilityDXR"); + // Input Uniforms + cmd.SetRayTracingFloatParam(rtsdtParams.screenSpaceShadowRT, HDShaderIDs._DirectionalMaxRayLength, rtsdtParams.maxShadowLength); + // Set ray count texture cmd.SetRayTracingTextureParam(rtsdtParams.screenSpaceShadowRT, HDShaderIDs._RayCountTexture, rtsdtResources.rayCountTexture); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.shader index 9fa8c422cf5..b8327d6f1fd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.shader @@ -207,6 +207,9 @@ Shader "HDRP/Decal" HLSLPROGRAM #pragma multi_compile DECALS_3RT DECALS_4RT + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + #define SHADERPASS SHADERPASS_DBUFFER_MESH #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalProperties.hlsl" @@ -238,6 +241,8 @@ Shader "HDRP/Decal" Blend 0 SrcAlpha One HLSLPROGRAM + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE #define _MATERIAL_AFFECTS_EMISSION #define SHADERPASS SHADERPASS_FORWARD_EMISSIVE_MESH diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl index bea55bd6254..a99f0586b26 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl @@ -14,6 +14,11 @@ void GetSurfaceData(FragInputs input, float3 V, PositionInputs posInput, out Dec float2 offset = float2(normalToWorld[3][2], normalToWorld[3][3]); float2 texCoords = input.texCoord0.xy * scale + offset; #elif (SHADERPASS == SHADERPASS_DBUFFER_MESH) || (SHADERPASS == SHADERPASS_FORWARD_EMISSIVE_MESH) + + #ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group + LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x); + #endif + float fadeFactor = _DecalBlend; float2 texCoords = input.texCoord0.xy; #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs index 509ae94928a..7a6d54e5460 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs @@ -629,12 +629,12 @@ private void GetDecalVolumeDataAndBound(Matrix4x4 decalToWorld, Matrix4x4 worldT var influenceForwardVS = worldToView.MultiplyVector(influenceZ / influenceExtents.z); var influencePositionVS = worldToView.MultiplyPoint(pos); // place the mesh pivot in the center - m_Bounds[m_DecalDatasCount].center = influencePositionVS; + m_Bounds[m_DecalDatasCount].center = influencePositionVS; m_Bounds[m_DecalDatasCount].boxAxisX = influenceRightVS * influenceExtents.x; m_Bounds[m_DecalDatasCount].boxAxisY = influenceUpVS * influenceExtents.y; m_Bounds[m_DecalDatasCount].boxAxisZ = influenceForwardVS * influenceExtents.z; - m_Bounds[m_DecalDatasCount].scaleXY.Set(1.0f, 1.0f); - m_Bounds[m_DecalDatasCount].radius = influenceExtents.magnitude; + m_Bounds[m_DecalDatasCount].scaleXY = 1.0f; + m_Bounds[m_DecalDatasCount].radius = influenceExtents.magnitude; // The culling system culls pixels that are further // than a threshold to the box influence extents. @@ -1197,15 +1197,15 @@ public void Cleanup() m_Atlas = null; } - public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width) + public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, DebugDisplaySettings debugDisplaySettings, DebugOverlay debugOverlay) { if (debugDisplaySettings.data.decalsDebugSettings.displayAtlas) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DisplayDebugDecalsAtlas))) { - cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); + debugOverlay.SetViewport(cmd); HDUtils.BlitQuad(cmd, Atlas.AtlasTexture, new Vector4(1, 1, 0, 0), new Vector4(1, 1, 0, 0), (int)debugDisplaySettings.data.decalsDebugSettings.mipLevel, true); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + debugOverlay.Next(); } } } 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 8e29f0b7972..4edf9209fa1 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 @@ -1029,7 +1029,6 @@ Shader "HDRP/LayeredLit" #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/ShaderLibrary/ShaderVariables.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" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader index 67a7f850f35..d778a5b9352 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader @@ -519,8 +519,7 @@ Shader "HDRP/LayeredLitTessellation" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl" //------------------------------------------------------------------------------------- // variable declaration @@ -560,6 +559,7 @@ Shader "HDRP/LayeredLitTessellation" #define SHADERPASS SHADERPASS_DEPTH_ONLY #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl" @@ -613,6 +613,7 @@ Shader "HDRP/LayeredLitTessellation" #ifdef DEBUG_DISPLAY #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitSharePass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl" @@ -646,6 +647,7 @@ Shader "HDRP/LayeredLitTessellation" #undef TESSELLATION_ON #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitSharePass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl" @@ -682,6 +684,7 @@ Shader "HDRP/LayeredLitTessellation" #pragma multi_compile _ WRITE_MSAA_DEPTH #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" @@ -716,6 +719,7 @@ Shader "HDRP/LayeredLitTessellation" HLSLPROGRAM #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl" @@ -757,6 +761,7 @@ Shader "HDRP/LayeredLitTessellation" #pragma multi_compile _ WRITE_MSAA_DEPTH #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator @@ -817,6 +822,7 @@ Shader "HDRP/LayeredLitTessellation" #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #ifdef DEBUG_DISPLAY 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 fe0876760b5..ddd32fe71c9 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 @@ -1061,7 +1061,6 @@ Shader "HDRP/Lit" #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" #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" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader index c74307dfbc8..de06161e0f1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader @@ -342,7 +342,6 @@ Shader "HDRP/LitTessellation" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl" - #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" //------------------------------------------------------------------------------------- // variable declaration @@ -379,6 +378,7 @@ Shader "HDRP/LitTessellation" // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation #define SHADERPASS SHADERPASS_DEPTH_ONLY #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -432,6 +432,7 @@ Shader "HDRP/LitTessellation" #ifdef DEBUG_DISPLAY #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitSharePass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -465,6 +466,7 @@ Shader "HDRP/LitTessellation" #undef TESSELLATION_ON #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitSharePass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -492,6 +494,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -533,6 +536,7 @@ Shader "HDRP/LitTessellation" #pragma multi_compile _ WRITE_MSAA_DEPTH #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator @@ -577,6 +581,7 @@ Shader "HDRP/LitTessellation" #pragma multi_compile _ WRITE_MSAA_DEPTH #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" @@ -617,6 +622,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDistortionPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -642,6 +648,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -682,6 +689,7 @@ Shader "HDRP/LitTessellation" #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #ifdef DEBUG_DISPLAY @@ -754,6 +762,7 @@ Shader "HDRP/LitTessellation" #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #ifdef DEBUG_DISPLAY @@ -797,6 +806,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.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/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl index 3c08ecd5dc9..8e776624000 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl @@ -125,37 +125,6 @@ void DoAlphaTest(float alpha, float alphaCutoff, out bool alphaTestResult) { alphaTestResult = alpha >= alphaCutoff; } -//----------------------------------------------------------------------------- -// LoD Fade -//----------------------------------------------------------------------------- - -// Helper for LODDitheringTransition. -uint2 ComputeFadeMaskSeed(float3 V, uint2 positionSS) -{ - uint2 fadeMaskSeed; - - if (IsPerspectiveProjection()) - { - // Start with the world-space direction V. It is independent from the orientation of the camera, - // and only depends on the position of the camera and the position of the fragment. - // Now, project and transform it into [-1, 1]. - float2 pv = PackNormalOctQuadEncode(V); - // Rescale it to account for the resolution of the screen. - pv *= _ScreenSize.xy; - // The camera only sees a small portion of the sphere, limited by hFoV and vFoV. - // Therefore, we must rescale again (before quantization), roughly, by 1/tan(FoV/2). - pv *= UNITY_MATRIX_P._m00_m11; - // Truncate and quantize. - fadeMaskSeed = asuint((int2)pv); - } - else - { - // Can't use the view direction, it is the same across the entire screen. - fadeMaskSeed = positionSS; - } - - return fadeMaskSeed; -} //----------------------------------------------------------------------------- // Reflection / Refraction hierarchy handling diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs index 14e3da365f7..477e5b4bbab 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs @@ -64,16 +64,6 @@ void InitSSSBuffers() // Caution: must be same format as m_CameraSssDiffuseLightingBuffer m_SSSCameraFilteringBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.B10G11R11_UFloatPack32, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, name: "SSSCameraFiltering"); // Enable UAV } - - // fill the list with the max number of diffusion profile so we dont have - // the error: exceeds previous array size (5 vs 3). Cap to previous size. - m_SSSShapeParamsAndMaxScatterDists = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSTransmissionTintsAndFresnel0 = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSDisabledTransmissionTintsAndFresnel0 = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSWorldScalesAndFilterRadiiAndThicknessRemaps = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSDiffusionProfileHashes = new uint[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSDiffusionProfileUpdate = new int[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; - m_SSSSetDiffusionProfiles = new DiffusionProfileSettings[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; } void DestroySSSBuffers() @@ -112,6 +102,16 @@ void InitializeSubsurfaceScattering() m_SSSDefaultDiffusionProfile = defaultResources.assets.defaultDiffusionProfile; + // fill the list with the max number of diffusion profile so we dont have + // the error: exceeds previous array size (5 vs 3). Cap to previous size. + m_SSSShapeParamsAndMaxScatterDists = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSTransmissionTintsAndFresnel0 = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSDisabledTransmissionTintsAndFresnel0 = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSWorldScalesAndFilterRadiiAndThicknessRemaps = new Vector4[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSDiffusionProfileHashes = new uint[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSDiffusionProfileUpdate = new int[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + m_SSSSetDiffusionProfiles = new DiffusionProfileSettings[DiffusionProfileConstants.DIFFUSION_PROFILE_COUNT]; + // If ray tracing is supported by the asset, do the initialization if (rayTracingSupported) InitializeSubsurfaceScatteringRT(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManagerRT.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManagerRT.cs index bb92856ef8f..b7f2551b2d0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManagerRT.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManagerRT.cs @@ -467,7 +467,13 @@ TextureHandle RenderSubsurfaceScatteringRT(RenderGraph renderGraph, HDCamera hdC rtsssResult = DenoiseRTSSS(renderGraph, hdCamera, rtsssResult, depthStencilBuffer, normalBuffer, motionVectorsBuffer); // Compose it - return CombineRTSSS(renderGraph, hdCamera, rtsssResult, depthStencilBuffer, sssColor, ssgiBuffer, diffuseBuffer, colorBuffer); + rtsssResult = CombineRTSSS(renderGraph, hdCamera, rtsssResult, depthStencilBuffer, sssColor, ssgiBuffer, diffuseBuffer, colorBuffer); + + // Push this version of the texture for debug + PushFullScreenDebugTexture(renderGraph, diffuseBuffer, FullScreenDebugMode.RayTracedSubSurface); + + // Return the result + return rtsssResult; } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Bloom.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Bloom.cs index 1e58ba5da77..9e2dfc2e86b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Bloom.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Bloom.cs @@ -90,6 +90,26 @@ public BloomResolution resolution set { m_Resolution.value = value; } } + /// + /// When enabled, bloom uses bicubic sampling instead of bilinear sampling for the upsampling passes. + /// + public bool highQualityPrefiltering + { + get + { + if (!UsesQualitySettings()) + { + return m_HighQualityPrefiltering.value; + } + else + { + int qualityLevel = (int)quality.levelAndOverride.level; + return GetPostProcessingQualitySettings().BloomHighQualityPrefiltering[qualityLevel]; + } + } + set { m_HighQualityPrefiltering.value = value; } + } + /// /// When enabled, bloom uses bicubic sampling instead of bilinear sampling for the upsampling passes. /// @@ -114,6 +134,10 @@ public bool highQualityFiltering [SerializeField, FormerlySerializedAs("resolution")] private BloomResolutionParameter m_Resolution = new BloomResolutionParameter(BloomResolution.Half); + [Tooltip("When enabled, bloom uses multiple bilinear samples for the prefiltering pass.")] + [SerializeField] + private BoolParameter m_HighQualityPrefiltering = new BoolParameter(false); + [Tooltip("When enabled, bloom uses bicubic sampling instead of bilinear sampling for the upsampling passes.")] [SerializeField, FormerlySerializedAs("highQualityFiltering")] private BoolParameter m_HighQualityFiltering = new BoolParameter(true); diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs index 7cc45541e43..e497825a88e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs @@ -30,12 +30,6 @@ class AlphaCopyPassData public TextureHandle outputAlpha; } - class GuardBandPassData - { - public ClearWithGuardBandsParameters parameters; - public TextureHandle source; - } - class StopNaNPassData { public StopNaNParameters parameters; @@ -235,23 +229,6 @@ TextureHandle DoCopyAlpha(RenderGraph renderGraph, HDCamera hdCamera, TextureHan return renderGraph.defaultResources.whiteTextureXR; } - TextureHandle ClearWithGuardBands(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source) - { - using (var builder = renderGraph.AddRenderPass("Guard Band Clear", out var passData, ProfilingSampler.Get(HDProfileId.GuardBandClear))) - { - passData.source = builder.WriteTexture(source); - passData.parameters = PrepareClearWithGuardBandsParameters(hdCamera); - - builder.SetRenderFunc( - (GuardBandPassData data, RenderGraphContext ctx) => - { - ClearWithGuardBands(data.parameters, ctx.cmd, data.source); - }); - - return passData.source; - } - } - TextureHandle StopNaNsPass(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source) { // Optional NaN killer before post-processing kicks in @@ -1016,9 +993,6 @@ public void Render(RenderGraph renderGraph, if (m_PostProcessEnabled) { - - source = ClearWithGuardBands(renderGraph, hdCamera, source); - source = StopNaNsPass(renderGraph, hdCamera, source); source = DynamicExposurePass(renderGraph, hdCamera, source); diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 65b576db1b1..7a764f83d7a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -215,9 +215,6 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources ); FillEmptyExposureTexture(); - - // Call after initializing m_LutSize and m_KeepAlpha as it's needed for render target allocation. - InitializeNonRenderGraphResources(hdAsset); } public void Cleanup() @@ -452,27 +449,6 @@ ClearWithGuardBandsParameters PrepareClearWithGuardBandsParameters(HDCamera came return parameters; } - static void ClearWithGuardBands(in ClearWithGuardBandsParameters parameters, CommandBuffer cmd, RTHandle source) - { - // Guard bands (also known as "horrible hack") to avoid bleeding previous RTHandle - // content into smaller viewports with some effects like Bloom that rely on bilinear - // filtering and can't use clamp sampler and the likes - // Note: some platforms can't clear a partial render target so we directly draw black triangles - { - int w = parameters.cameraWidth; - int h = parameters.cameraHeight; - cmd.SetRenderTarget(source, 0, CubemapFace.Unknown, -1); - - if (w < source.rt.width || h < source.rt.height) - { - cmd.SetViewport(new Rect(w, 0, k_RTGuardBandSize, h)); - cmd.DrawProcedural(Matrix4x4.identity, parameters.clearMaterial, 0, MeshTopology.Triangles, 3, 1); - cmd.SetViewport(new Rect(0, h, w + k_RTGuardBandSize, k_RTGuardBandSize)); - cmd.DrawProcedural(Matrix4x4.identity, parameters.clearMaterial, 0, MeshTopology.Triangles, 3, 1); - } - } - } - public void Render(CommandBuffer cmd, HDCamera camera, BlueNoise blueNoise, RTHandle colorBuffer, RTHandle afterPostProcessTexture, RenderTargetIdentifier finalRT, RTHandle depthBuffer, RTHandle depthMipChain, RTHandle motionVecTexture, bool flipY) { var dynResHandler = DynamicResolutionHandler.instance; @@ -500,8 +476,6 @@ void PoolSource(ref RTHandle src, RTHandle dst) if (m_PostProcessEnabled) { - ClearWithGuardBands(PrepareClearWithGuardBandsParameters(camera), cmd, source); - // Optional NaN killer before post-processing kicks in bool stopNaNs = camera.stopNaNs && m_StopNaNFS; @@ -911,6 +885,8 @@ struct UberPostParameters public Vector4 bloomBicubicParams; public Vector4 bloomDirtTileOffset; public Vector4 bloomThreshold; + + public Vector4 alphaScaleBias; } UberPostParameters PrepareUberPostParameters(HDCamera hdCamera, bool isSceneView) @@ -944,10 +920,23 @@ UberPostParameters PrepareUberPostParameters(HDCamera hdCamera, bool isSceneView PrepareChromaticAberrationParameters(ref parameters, featureFlags); PrepareVignetteParameters(ref parameters, featureFlags); PrepareUberBloomParameters(ref parameters, hdCamera); + PrepareAlphaScaleParameters(ref parameters, hdCamera); return parameters; } + void PrepareAlphaScaleParameters(ref UberPostParameters parameters, HDCamera camera) + { + if (m_EnableAlpha) + { + parameters.alphaScaleBias = Compositor.CompositionManager.GetAlphaScaleAndBiasForCamera(camera); + } + else + { + parameters.alphaScaleBias = new Vector4(1.0f, 0.0f, 0.0f, 0.0f); + } + } + static void DoUberPostProcess(in UberPostParameters parameters, RTHandle source, RTHandle destination, @@ -982,6 +971,8 @@ static void DoUberPostProcess(in UberPostParameters parameters, cmd.SetComputeVectorParam(parameters.uberPostCS, HDShaderIDs._BloomDirtScaleOffset, parameters.bloomDirtTileOffset); cmd.SetComputeVectorParam(parameters.uberPostCS, HDShaderIDs._BloomThreshold, parameters.bloomThreshold); + // Alpha scale and bias (only used when alpha is enabled) + cmd.SetComputeVectorParam(parameters.uberPostCS, HDShaderIDs._AlphaScaleBias, parameters.alphaScaleBias); // Dispatch uber post cmd.SetComputeVectorParam(parameters.uberPostCS, "_DebugFlags", new Vector4(parameters.outputColorLog ? 1 : 0, 0, 0, 0)); @@ -2466,23 +2457,43 @@ static void DoDepthOfField(in DepthOfFieldParameters dofParameters, CommandBuffe } } + static RTHandle CoCAllocatorMipsTrue(string id, int frameIndex, RTHandleSystem rtHandleSystem) + { + return rtHandleSystem.Alloc( + Vector2.one, TextureXR.slices, DepthBits.None, GraphicsFormat.R16_SFloat, + dimension: TextureXR.dimension, enableRandomWrite: true, useMipMap: true, useDynamicScale: true, name: $"{id} CoC History" + ); + } + + static RTHandle CoCAllocatorMipsFalse(string id, int frameIndex, RTHandleSystem rtHandleSystem) + { + return rtHandleSystem.Alloc( + Vector2.one, TextureXR.slices, DepthBits.None, GraphicsFormat.R16_SFloat, + dimension: TextureXR.dimension, enableRandomWrite: true, useMipMap: false, useDynamicScale: true, name: $"{id} CoC History" + ); + } + static void GrabCoCHistory(HDCamera camera, out RTHandle previous, out RTHandle next, bool useMips = false) { - RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSystem) + // WARNING WORKAROUND + // For some reason, the Allocator as it was declared before would capture the useMips parameter but only when both render graph and XR are enabled. + // To work around this we have two hard coded allocators and use one or the other depending on the parameters. + // Also don't try to put the right allocator in a temporary variable as it will also generate allocations hence the horrendous copy paste bellow. + if (useMips) { - return rtHandleSystem.Alloc( - Vector2.one, TextureXR.slices, DepthBits.None, GraphicsFormat.R16_SFloat, - dimension: TextureXR.dimension, enableRandomWrite: true, useMipMap:useMips, useDynamicScale: true, name: $"{id} CoC History" - ); + next = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC) + ?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, CoCAllocatorMipsTrue, 2); + } + else + { + next = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC) + ?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, CoCAllocatorMipsFalse, 2); } - - next = camera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC) - ?? camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, Allocator, 2); if (useMips == true && next.rt.mipmapCount == 1) { camera.ReleaseHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC); - next = camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, Allocator, 2); + next = camera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC, CoCAllocatorMipsTrue, 2); } previous = camera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.DepthOfFieldCoC); @@ -3030,6 +3041,12 @@ BloomParameters PrepareBloomParameters(HDCamera camera) parameters.bloomPrefilterCS = m_Resources.shaders.bloomPrefilterCS; parameters.bloomPrefilterKernel = parameters.bloomPrefilterCS.FindKernel("KMain"); + parameters.bloomPrefilterCS.shaderKeywords = null; + if (m_Bloom.highQualityPrefiltering) + parameters.bloomPrefilterCS.EnableKeyword("HIGH_QUALITY"); + else + parameters.bloomPrefilterCS.EnableKeyword("LOW_QUALITY"); + parameters.bloomBlurCS = m_Resources.shaders.bloomBlurCS; parameters.bloomBlurKernel = parameters.bloomBlurCS.FindKernel("KMain"); parameters.bloomDownsampleKernel = parameters.bloomBlurCS.FindKernel("KDownsample"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomBlur.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomBlur.compute index ab1c9e5f81c..e61fdcbfb8b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomBlur.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomBlur.compute @@ -5,7 +5,7 @@ #pragma only_renderers d3d11 playstation xboxone vulkan metal switch -#pragma kernel KMain MAIN=KMain +#pragma kernel KMain MAIN=KMain #pragma kernel KDownsample MAIN=KDownsample DOWNSAMPLE @@ -13,8 +13,6 @@ TEXTURE2D_X(_InputTexture); RW_TEXTURE2D_X(float3, _OutputTexture); -SAMPLER(sampler_LinearClamp); - CBUFFER_START(cb0) float4 _TexelSize; // xy: size, zw: texel size CBUFFER_END @@ -113,10 +111,10 @@ void MAIN(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, ui #if DOWNSAMPLE float2 offset = float2(threadUL); float2 maxCoord = 1.0 - 0.5f *_TexelSize.zw; - float3 p00 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear((offset + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; - float3 p10 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear((offset + float2(1.0, 0.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; - float3 p01 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear((offset + float2(0.0, 1.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; - float3 p11 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear((offset + float2(1.0, 1.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; + float3 p00 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampAndScaleUVForBilinear((offset + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; + float3 p10 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampAndScaleUVForBilinear((offset + float2(1.0, 0.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; + float3 p01 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampAndScaleUVForBilinear((offset + float2(0.0, 1.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; + float3 p11 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampAndScaleUVForBilinear((offset + float2(1.0, 1.0) + 0.5) * _TexelSize.zw, _TexelSize.zw), 0.0).xyz; #else uint2 uthreadUL = uint2(max(0, threadUL)); uint2 size = uint2(_TexelSize.xy) - 1u; diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute index 627a1294a87..d3bf654057e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomPrefilter.compute @@ -7,17 +7,31 @@ #pragma kernel KMain +#pragma multi_compile LOW_QUALITY HIGH_QUALITY + TEXTURE2D_X(_InputTexture); RW_TEXTURE2D_X(float3, _OutputTexture); -SAMPLER(sampler_LinearClamp); - CBUFFER_START(cb0) float4 _TexelSize; float4 _BloomThreshold; CBUFFER_END +float3 BilinearSample(float2 uv, float2 offset, out float weight) +{ + float3 c = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampAndScaleUVForBilinear(uv + offset * _ScreenSize.zw), 0.0).xyz; + c = QuadraticThreshold(c, _BloomThreshold.x, _BloomThreshold.yzw); + + weight = 1.0 / (Luminance(c) + 1.0); + return c; +} + +float3 PartialAverage(float3 c0, float3 c1, float3 c2, float3 c3, float w0, float w1, float w2, float w3) +{ + return (c0*w0 + c1*w1 + c2*w2 + c3*w3) / (w0 + w1 + w2 + w3); +} + #define GROUP_SIZE 8 [numthreads(GROUP_SIZE, GROUP_SIZE, 1)] @@ -27,6 +41,7 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _TexelSize.zw, uint2(GROUP_SIZE, GROUP_SIZE)); float2 uv = posInputs.positionNDC; +#if LOW_QUALITY // Use a rotated grid to minimize artifacts coming from horizontal and vertical boundaries // "High Quality Antialiasing" [Lorach07] const float2 kTaps[] = { @@ -37,24 +52,14 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) float2(-0.4, -0.9) }; - float3 color0 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(_TexelSize.zw * kTaps[0] + uv, _TexelSize.zw), 0.0).xyz; - float3 color1 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(_TexelSize.zw * kTaps[1] + uv, _TexelSize.zw), 0.0).xyz; - float3 color2 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(_TexelSize.zw * kTaps[2] + uv, _TexelSize.zw), 0.0).xyz; - float3 color3 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(_TexelSize.zw * kTaps[3] + uv, _TexelSize.zw), 0.0).xyz; - float3 color4 = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(_TexelSize.zw * kTaps[4] + uv, _TexelSize.zw), 0.0).xyz; - - color0 = QuadraticThreshold(color0, _BloomThreshold.x, _BloomThreshold.yzw); - color1 = QuadraticThreshold(color1, _BloomThreshold.x, _BloomThreshold.yzw); - color2 = QuadraticThreshold(color2, _BloomThreshold.x, _BloomThreshold.yzw); - color3 = QuadraticThreshold(color3, _BloomThreshold.x, _BloomThreshold.yzw); - color4 = QuadraticThreshold(color4, _BloomThreshold.x, _BloomThreshold.yzw); + float w0, w1, w2, w3, w4; + float3 color0 = BilinearSample(uv, kTaps[0], w0); + float3 color1 = BilinearSample(uv, kTaps[1], w1); + float3 color2 = BilinearSample(uv, kTaps[2], w2); + float3 color3 = BilinearSample(uv, kTaps[3], w3); + float3 color4 = BilinearSample(uv, kTaps[4], w4); // Luma weighted average [Karis13] - float w0 = 1.0 / (Luminance(color0) + 1.0); - float w1 = 1.0 / (Luminance(color1) + 1.0); - float w2 = 1.0 / (Luminance(color2) + 1.0); - float w3 = 1.0 / (Luminance(color3) + 1.0); - float w4 = 1.0 / (Luminance(color4) + 1.0); float wSum = w0 + w1 + w2 + w3 + w4; color0 *= w0; @@ -65,9 +70,33 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) float3 acc = color0 + color1 + color2 + color3 + color4; float3 output = acc / wSum; +#else + // "Post-Processing in CoD Advanced Warfare" [Jimenez14] + float wA, wB, wC, wD, wE, wF, wG, wH, wI, wJ, wK, wL, wM; + float3 A = BilinearSample(uv, float2(-1.0, -1.0), wA); + float3 B = BilinearSample(uv, float2( 0.0, -1.0), wB); + float3 C = BilinearSample(uv, float2( 1.0, -1.0), wC); + float3 D = BilinearSample(uv, float2(-0.5, -0.5), wD); + float3 E = BilinearSample(uv, float2( 0.5, -0.5), wE); + float3 F = BilinearSample(uv, float2(-1.0, 0.0), wF); + float3 G = BilinearSample(uv, float2( 0.0, 0.0), wG); + float3 H = BilinearSample(uv, float2( 1.0, 0.0), wH); + float3 I = BilinearSample(uv, float2(-0.5, 0.5), wI); + float3 J = BilinearSample(uv, float2( 0.5, 0.5), wJ); + float3 K = BilinearSample(uv, float2(-1.0, 1.0), wK); + float3 L = BilinearSample(uv, float2( 0.0, 1.0), wL); + float3 M = BilinearSample(uv, float2( 1.0, 1.0), wM); + + float3 output = 0; + output += PartialAverage(D, E, I, J, wD, wE, wI, wJ) * 0.5; + output += PartialAverage(A, B, F, G, wA, wB, wF, wG) * 0.125; + output += PartialAverage(B, C, G, H, wB, wC, wG, wH) * 0.125; + output += PartialAverage(F, G, K, L, wF, wG, wK, wL) * 0.125; + output += PartialAverage(G, H, L, M, wG, wH, wL, wM) * 0.125; +#endif // Guard bands - output *= all(dispatchThreadId.xy < uint2(_TexelSize.xy)); + output *= all(dispatchThreadId.xy <= uint2(_TexelSize.xy)); _OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = output; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute index dba4a7cbe48..ca40036677d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/BloomUpsample.compute @@ -4,7 +4,7 @@ #pragma only_renderers d3d11 playstation xboxone vulkan metal switch -#pragma kernel KMain +#pragma kernel KMain #pragma multi_compile LOW_QUALITY HIGH_QUALITY @@ -13,8 +13,6 @@ TEXTURE2D_X(_InputHighTexture); RW_TEXTURE2D_X(float3, _OutputTexture); -SAMPLER(sampler_LinearClamp); - CBUFFER_START(cb0) float4 _Params; // x: scatter, yzw: unused float4 _BloomBicubicParams; // xy: low src size, zw: low src texel size @@ -30,20 +28,20 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) { UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z); PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _TexelSize.zw, uint2(GROUP_SIZE, GROUP_SIZE)); - float2 uv = ClampAndScaleUVForBilinear(posInputs.positionNDC, _TexelSize.zw) ; - float3 highRes = LOAD_TEXTURE2D_X(_InputHighTexture, posInputs.positionSS).xyz; + float2 uv = ClampAndScaleUV(posInputs.positionNDC, _BloomBicubicParams.zw, 1.0f); + float3 highRes = LOAD_TEXTURE2D_X(_InputHighTexture, clamp(posInputs.positionSS, 0, _TexelSize.xy - 1)).xyz; #if LOW_QUALITY - float3 lowRes = SAMPLE_TEXTURE2D_X_LOD(_InputLowTexture, sampler_LinearClamp, uv, 0.0).xyz; + float3 lowRes = SAMPLE_TEXTURE2D_X_LOD(_InputLowTexture, s_linear_clamp_sampler, uv, 0.0).xyz; #else // HIGH_QUALITY float2 maxCoord = (1.0f - _TexelSize.zw) * _RTHandleScale.xy; - float3 lowRes = SampleTexture2DBicubic(TEXTURE2D_X_ARGS(_InputLowTexture, sampler_LinearClamp), uv, _BloomBicubicParams, maxCoord, unity_StereoEyeIndex).xyz; + float3 lowRes = SampleTexture2DBicubic(TEXTURE2D_X_ARGS(_InputLowTexture, s_linear_clamp_sampler), uv, _BloomBicubicParams, maxCoord, unity_StereoEyeIndex).xyz; #endif float3 output = lerp(highRes, lowRes, Scatter); // Guard bands - output *= all(dispatchThreadId.xy < uint2(_TexelSize.xy)); + output *= all(dispatchThreadId.xy <= uint2(_TexelSize.xy)); _OutputTexture[COORD_TEXTURE2D_X(dispatchThreadId.xy)] = output; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute index fc7f62c8c4d..37c341a1efb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute @@ -97,13 +97,9 @@ void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID) float mip = min(kMaxMips, (1.0 / (SampleCount - 1.5)) * samp0CoC * Radius); #endif - // Avoid bleeding with the RTHandle autosize system -#if FAR - // A bit more generous maxCoord because of trilinear being involved. - float texelsToClamp = 2.0f; -#else - float texelsToClamp = 1.0f; -#endif + uint mipCeiled = ceil(mip); + float texelsToClamp = (1u << mipCeiled) + 1; + float4 acc = 0.0; float nearWeightAcc = 0.0; float accAlpha = 0.0; diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute index 8a0b252c5a1..f49084bdbd2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute @@ -44,6 +44,7 @@ CBUFFER_START(cb0) float4 _BloomDirtScaleOffset; float4 _BloomBicubicParams; float4 _DebugFlags; + float4 _AlphaScaleBias; CBUFFER_END #define DistCenter _DistortionParams1.xy @@ -77,6 +78,9 @@ CBUFFER_END #define OutputLogEnabled _DebugFlags.x +#define AlphaScale _AlphaScaleBias.x +#define AlphaBias _AlphaScaleBias.y + float2 DistortUV(float2 uv) { // Lens distortion @@ -218,8 +222,10 @@ void Uber(uint3 dispatchThreadId : SV_DispatchThreadID) // Alpha mask #ifdef ENABLE_ALPHA // Post processing is not applied on pixels with zero alpha + // The alpha scale and bias control how steep is the transition between the post-processed and plain regions + float alpha = inputColor.a * AlphaScale + AlphaBias; // Saturate is necessary to avoid issues when additive blending pushes the alpha over 1. - color.xyz = lerp(inputColor.xyz, color.xyz, saturate(inputColor.a)); + color.xyz = lerp(inputColor.xyz, color.xyz, saturate(alpha)); #endif // Done diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/Shaders/Accumulation.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/Shaders/Accumulation.compute index 9f5ca00ba16..2b9c8159d3f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/Shaders/Accumulation.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Accumulation/Shaders/Accumulation.compute @@ -4,8 +4,13 @@ #pragma kernel KMain +#pragma multi_compile _ INPUT_FROM_RADIANCE_TEXTURE + // Inputs +#ifdef INPUT_FROM_RADIANCE_TEXTURE TEXTURE2D_X(_RadianceTexture); +#endif + float4 _AccumulationWeights; int _AccumulationNeedsExposure; uint _AccumulationFrameIndex; @@ -55,8 +60,12 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID) _CameraColorTextureRW[COORD_TEXTURE2D_X(currentPixelCoord)] = float4(_AccumulatedFrameTexture[COORD_TEXTURE2D_X(currentPixelCoord)].xyz * exposureMultiplier, 1.0); } else - { + { +#ifdef INPUT_FROM_RADIANCE_TEXTURE float4 color = _RadianceTexture[COORD_TEXTURE2D_X(dispatchThreadId.xy)]; +#else + float4 color = _CameraColorTextureRW[COORD_TEXTURE2D_X(dispatchThreadId.xy)]; +#endif if (sampleCount++) color.xyz = (_AccumulatedFrameTexture[COORD_TEXTURE2D_X(currentPixelCoord)].xyz * _AccumulationWeights.y + _AccumulationWeights.x * color.xyz) * _AccumulationWeights.z; 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 77a31cadace..640f179af0b 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 @@ -291,7 +291,7 @@ struct RenderAccumulationParameters public HDCamera hdCamera; } - RenderAccumulationParameters PrepareRenderAccumulationParameters(HDCamera hdCamera, bool needExposure) + RenderAccumulationParameters PrepareRenderAccumulationParameters(HDCamera hdCamera, bool needExposure, bool inputFromRadianceTexture) { var parameters = new RenderAccumulationParameters(); @@ -301,6 +301,11 @@ RenderAccumulationParameters PrepareRenderAccumulationParameters(HDCamera hdCame parameters.needExposure = needExposure; parameters.hdCamera = hdCamera; + parameters.accumulationCS.shaderKeywords = null; + if (inputFromRadianceTexture) + { + parameters.accumulationCS.EnableKeyword("INPUT_FROM_RADIANCE_TEXTURE"); + } return parameters; } @@ -310,7 +315,8 @@ void RenderAccumulation(HDCamera hdCamera, RTHandle inputTexture, RTHandle outpu RTHandle history = hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing) ?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1); - var parameters = PrepareRenderAccumulationParameters(hdCamera, needExposure); + bool inputFromRadianceTexture = !inputTexture.Equals(outputTexture); + var parameters = PrepareRenderAccumulationParameters(hdCamera, needExposure, inputFromRadianceTexture); RenderAccumulation(parameters, inputTexture, outputTexture, history, cmd); } @@ -332,7 +338,10 @@ static void RenderAccumulation(in RenderAccumulationParameters parameters, RTHan cmd.SetComputeIntParam(accumulationShader, HDShaderIDs._AccumulationNumSamples, (int)parameters.subFrameManager.subFrameCount); cmd.SetComputeTextureParam(accumulationShader, parameters.accumulationKernel, HDShaderIDs._AccumulatedFrameTexture, historyTexture); cmd.SetComputeTextureParam(accumulationShader, parameters.accumulationKernel, HDShaderIDs._CameraColorTextureRW, outputTexture); - cmd.SetComputeTextureParam(accumulationShader, parameters.accumulationKernel, HDShaderIDs._RadianceTexture, inputTexture); + if (!inputTexture.Equals(outputTexture)) + { + cmd.SetComputeTextureParam(accumulationShader, parameters.accumulationKernel, HDShaderIDs._RadianceTexture, inputTexture); + } cmd.SetComputeVectorParam(accumulationShader, HDShaderIDs._AccumulationWeights, frameWeights); cmd.SetComputeIntParam(accumulationShader, HDShaderIDs._AccumulationNeedsExposure, parameters.needExposure ? 1 : 0); cmd.DispatchCompute(accumulationShader, parameters.accumulationKernel, (parameters.hdCamera.actualWidth + 7) / 8, (parameters.hdCamera.actualHeight + 7) / 8, parameters.hdCamera.viewCount); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs index 2710fc3a8c3..489040faf1c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/GlobalPostProcessingQualitySettings.cs @@ -101,6 +101,10 @@ internal GlobalPostProcessingQualitySettings() BloomHighQualityFiltering[(int)ScalableSettingLevelParameter.Level.Medium] = true; BloomHighQualityFiltering[(int)ScalableSettingLevelParameter.Level.High] = true; + BloomHighQualityPrefiltering[(int)ScalableSettingLevelParameter.Level.Low] = false; + BloomHighQualityPrefiltering[(int)ScalableSettingLevelParameter.Level.Medium] = false; + BloomHighQualityPrefiltering[(int)ScalableSettingLevelParameter.Level.High] = true; + /* Chromatic Aberration */ ChromaticAberrationMaxSamples[(int)ScalableSettingLevelParameter.Level.Low] = 3; ChromaticAberrationMaxSamples[(int)ScalableSettingLevelParameter.Level.Medium] = 6; @@ -132,8 +136,10 @@ internal GlobalPostProcessingQualitySettings() /* Bloom */ /// Bloom resolution for each quality level. public BloomResolution[] BloomRes = new BloomResolution[s_QualitySettingCount]; - /// Use bloom high quality filtering for each quality level. + /// Bloom high quality filtering for each quality level. public bool[] BloomHighQualityFiltering = new bool[s_QualitySettingCount]; + /// Bloom high quality prefiltering for each quality level. + public bool[] BloomHighQualityPrefiltering = new bool[s_QualitySettingCount]; /* Chromatic Aberration */ /// Chromatic aberration maximum sample count for each quality level. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs index 03c1236f7b4..e1c1f35a044 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs @@ -18,6 +18,7 @@ internal enum HDProfileId ScreenSpaceShadows, ScreenSpaceShadowsDebug, BuildLightList, + GenerateLightAABBs, ContactShadows, BlitToFinalRTDevBuildOnly, Distortion, @@ -115,6 +116,7 @@ internal enum HDProfileId // RT Cluster RaytracingBuildCluster, RaytracingCullLights, + RaytracingDebugCluster, // RTR RaytracingReflectionDirectionGeneration, RaytracingReflectionEvaluation, @@ -189,7 +191,6 @@ internal enum HDProfileId UpsampleLowResTransparent, // Post-processing - GuardBandClear, AlphaCopy, StopNaNs, FixedExposure, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs index e19f5b8875b..4d0af913e9c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs @@ -6,6 +6,7 @@ namespace UnityEngine.Rendering.HighDefinition { public partial class HDRenderPipeline { + DebugOverlay m_DebugOverlay = new DebugOverlay(); TextureHandle m_DebugFullScreenTexture; ComputeBufferHandle m_DebugFullScreenComputeBuffer; @@ -108,7 +109,12 @@ TextureHandle ResolveFullScreenDebug(RenderGraph renderGraph, in DebugParameters passData.debugParameters = debugParameters; passData.input = builder.ReadTexture(inputFullScreenDebug); passData.depthPyramid = builder.ReadTexture(depthPyramid); - passData.fullscreenBuffer = builder.ReadComputeBuffer(m_DebugFullScreenComputeBuffer); + // On Vulkan, not binding the Random Write Target will result in an invalid drawcall. + // To avoid that, if the compute buffer is invalid, we bind a dummy compute buffer anyway. + if (m_DebugFullScreenComputeBuffer.IsValid()) + passData.fullscreenBuffer = builder.ReadComputeBuffer(m_DebugFullScreenComputeBuffer); + else + passData.fullscreenBuffer = builder.CreateTransientComputeBuffer(new ComputeBufferDesc(4, sizeof(uint))); passData.output = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, name = "ResolveFullScreenDebug" })); @@ -148,50 +154,137 @@ TextureHandle ResolveColorPickerDebug(RenderGraph renderGraph, in DebugParameter } } - class RenderDebugOverlayPassData + class DebugOverlayPassData { public DebugParameters debugParameters; public TextureHandle colorBuffer; public TextureHandle depthBuffer; + } + + void RenderSkyReflectionOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer) + { + var lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; + if (!lightingDebug.displaySkyReflection) + return; + + using (var builder = renderGraph.AddRenderPass("SkyReflectionOverlay", out var passData)) + { + passData.debugParameters = debugParameters; + passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); + passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); + + builder.SetRenderFunc( + (DebugOverlayPassData data, RenderGraphContext ctx) => + { + RenderSkyReflectionOverlay(data.debugParameters, ctx.cmd, ctx.renderGraphPool.GetTempMaterialPropertyBlock()); + }); + } + } + + void RenderRayCountOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer) + { + if (!debugParameters.rayTracingSupported) + return; + + using (var builder = renderGraph.AddRenderPass("RenderRayCountOverlay", out var passData)) + { + passData.debugParameters = debugParameters; + passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); + passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); + + builder.SetRenderFunc( + (DebugOverlayPassData data, RenderGraphContext ctx) => + { + RenderRayCountOverlay(data.debugParameters, ctx.cmd); + }); + } + } + + class DebugLightLoopOverlayPassData + : DebugOverlayPassData + { public TextureHandle depthPyramidTexture; public ComputeBufferHandle tileList; public ComputeBufferHandle lightList; public ComputeBufferHandle perVoxelLightList; public ComputeBufferHandle dispatchIndirect; + } + + void RenderLightLoopDebugOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer, in BuildGPULightListOutput lightLists, TextureHandle depthPyramidTexture) + { + var lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; + if (lightingDebug.tileClusterDebug == TileClusterDebug.None + && !lightingDebug.displayCookieAtlas + && !lightingDebug.displayPlanarReflectionProbeAtlas) + return; + + using (var builder = renderGraph.AddRenderPass("RenderLightLoopDebugOverlay", out var passData)) + { + passData.debugParameters = debugParameters; + passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); + passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); + + if (lightingDebug.tileClusterDebug != TileClusterDebug.None) + { + passData.depthPyramidTexture = builder.ReadTexture(depthPyramidTexture); + passData.tileList = builder.ReadComputeBuffer(lightLists.tileList); + passData.lightList = builder.ReadComputeBuffer(lightLists.lightList); + passData.perVoxelLightList = builder.ReadComputeBuffer(lightLists.perVoxelLightLists); + passData.dispatchIndirect = builder.ReadComputeBuffer(lightLists.dispatchIndirectBuffer); + } + + builder.SetRenderFunc( + (DebugLightLoopOverlayPassData data, RenderGraphContext ctx) => + { + RenderLightLoopDebugOverlay(data.debugParameters, ctx.cmd, data.tileList, data.lightList, data.perVoxelLightList, data.dispatchIndirect, data.depthPyramidTexture); + + }); + } + } + + void RenderProbeVolumeDebugOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer) + { + if (!m_SupportProbeVolume || debugParameters.debugDisplaySettings.data.lightingDebugSettings.probeVolumeDebugMode == ProbeVolumeDebugMode.None) + return; + + using (var builder = renderGraph.AddRenderPass("RenderProbeVolumeDebugOverlay", out var passData)) + { + passData.debugParameters = debugParameters; + passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); + passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); + + builder.SetRenderFunc( + (DebugLightLoopOverlayPassData data, RenderGraphContext ctx) => + { + RenderProbeVolumeDebugOverlay(data.debugParameters, ctx.cmd); + }); + } + } + + class RenderShadowsDebugOverlayPassData + : DebugOverlayPassData + { public ShadowResult shadowTextures; } - void RenderDebugOverlays( RenderGraph renderGraph, - in DebugParameters debugParameters, - TextureHandle colorBuffer, - TextureHandle depthBuffer, - TextureHandle depthPyramidTexture, - in BuildGPULightListOutput lightLists, - in ShadowResult shadowResult) + void RenderShadowsDebugOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer, in ShadowResult shadowResult) { - using (var builder = renderGraph.AddRenderPass("DebugOverlay", out var passData)) + LightingDebugSettings lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; + if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.None) + return; + + using (var builder = renderGraph.AddRenderPass("RenderShadowsDebugOverlay", out var passData)) { passData.debugParameters = debugParameters; passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); - passData.depthPyramidTexture = builder.ReadTexture(depthPyramidTexture); passData.shadowTextures = HDShadowManager.ReadShadowResult(shadowResult, builder); - passData.tileList = builder.ReadComputeBuffer(lightLists.tileList); - passData.lightList = builder.ReadComputeBuffer(lightLists.lightList); - passData.perVoxelLightList = builder.ReadComputeBuffer(lightLists.perVoxelLightLists); - passData.dispatchIndirect = builder.ReadComputeBuffer(lightLists.dispatchIndirectBuffer); builder.SetRenderFunc( - (RenderDebugOverlayPassData data, RenderGraphContext ctx) => + (RenderShadowsDebugOverlayPassData data, RenderGraphContext ctx) => { var debugParams = data.debugParameters; - HDUtils.ResetOverlay(); - float x = 0.0f; - float overlayRatio = debugParams.debugDisplaySettings.data.debugOverlayRatio; - float overlaySize = Math.Min(debugParams.hdCamera.actualHeight, debugParams.hdCamera.actualWidth) * overlayRatio; - float y = debugParams.hdCamera.actualHeight - overlaySize; - var shadowAtlases = new HDShadowManager.ShadowDebugAtlasTextures(); shadowAtlases.punctualShadowAtlas = data.shadowTextures.punctualShadowResult; shadowAtlases.cascadeShadowAtlas = data.shadowTextures.directionalShadowResult; @@ -199,15 +292,47 @@ void RenderDebugOverlays( RenderGraph renderGraph, shadowAtlases.cachedPunctualShadowAtlas = data.shadowTextures.cachedPunctualShadowResult; shadowAtlases.cachedAreaShadowAtlas = data.shadowTextures.cachedAreaShadowResult; - RenderSkyReflectionOverlay(debugParams, ctx.cmd, ctx.renderGraphPool.GetTempMaterialPropertyBlock(), ref x, ref y, overlaySize); - RenderRayCountOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize); - RenderLightLoopDebugOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize, data.tileList, data.lightList, data.perVoxelLightList, data.dispatchIndirect, data.depthPyramidTexture); - RenderShadowsDebugOverlay(debugParams, shadowAtlases, ctx.cmd, ref x, ref y, overlaySize, ctx.renderGraphPool.GetTempMaterialPropertyBlock()); - DecalSystem.instance.RenderDebugOverlay(debugParams.hdCamera, ctx.cmd, debugParams.debugDisplaySettings, ref x, ref y, overlaySize, debugParams.hdCamera.actualWidth); + RenderShadowsDebugOverlay(debugParams, shadowAtlases, ctx.cmd, ctx.renderGraphPool.GetTempMaterialPropertyBlock()); }); } } + void RenderDecalOverlay(RenderGraph renderGraph, in DebugParameters debugParameters, TextureHandle colorBuffer, TextureHandle depthBuffer) + { + if (!debugParameters.debugDisplaySettings.data.decalsDebugSettings.displayAtlas) + return; + + using (var builder = renderGraph.AddRenderPass("SkyReflectionOverlay", out var passData)) + { + passData.debugParameters = debugParameters; + passData.colorBuffer = builder.UseColorBuffer(colorBuffer, 0); + passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); + + builder.SetRenderFunc( + (DebugOverlayPassData data, RenderGraphContext ctx) => + { + DecalSystem.instance.RenderDebugOverlay(data.debugParameters.hdCamera, ctx.cmd, data.debugParameters.debugDisplaySettings, data.debugParameters.debugOverlay); + }); + } + } + + void RenderDebugOverlays( RenderGraph renderGraph, + in DebugParameters debugParameters, + TextureHandle colorBuffer, + TextureHandle depthBuffer, + TextureHandle depthPyramidTexture, + in BuildGPULightListOutput lightLists, + in ShadowResult shadowResult) + { + + RenderSkyReflectionOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer); + RenderRayCountOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer); + RenderLightLoopDebugOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer, lightLists, depthPyramidTexture); + RenderProbeVolumeDebugOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer); + RenderShadowsDebugOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer, shadowResult); + RenderDecalOverlay(renderGraph, debugParameters, colorBuffer, depthBuffer); + } + class RenderLightVolumesPassData { public DebugLightVolumes.RenderLightVolumesParameters parameters; @@ -382,11 +507,15 @@ class DebugViewMaterialData public RendererListHandle transparentRendererList; public Material debugGBufferMaterial; public FrameSettings frameSettings; + + public Texture clearColorTexture; + public RenderTexture clearDepthTexture; } TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cull, HDCamera hdCamera) { bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); + var output = renderGraph.CreateTexture( new TextureDesc(Vector2.one, true, true) { @@ -432,9 +561,19 @@ TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cu rendererConfiguration: m_CurrentRendererConfigurationBakedLighting, stateBlock: m_DepthStateOpaque))); + passData.clearColorTexture = Compositor.CompositionManager.GetClearTextureForStackedCamera(hdCamera); // returns null if is not a stacked camera + passData.clearDepthTexture = Compositor.CompositionManager.GetClearDepthForStackedCamera(hdCamera); // returns null if is not a stacked camera + builder.SetRenderFunc( (DebugViewMaterialData data, RenderGraphContext context) => { + // If we are doing camera stacking, then we want to clear the debug color and depth buffer using the data from the previous camera on the stack + // Note: Ideally here we would like to draw directly on the same buffers as the previous camera, but currently the compositor is not using + // Texture Arrays so this would not work. We might need to revise this in the future. + if (data.clearColorTexture != null) + { + HDUtils.BlitColorAndDepth(context.cmd, data.clearColorTexture, data.clearDepthTexture, new Vector4(1, 1, 0, 0), 0, !hdCamera.clearDepth); + } DrawOpaqueRendererList(context, data.frameSettings, data.opaqueRendererList); DrawTransparentRendererList(context, data.frameSettings, data.transparentRendererList); }); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index 5f131d28a48..e2aa5304a96 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -204,7 +204,7 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph, // Bind the custom color/depth before the first custom pass BindCustomPassBuffers(renderGraph, hdCamera); - RenderCustomPass(renderGraph, hdCamera, colorBuffer, result.depthBuffer, result.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforeRendering, aovRequest, aovBuffers); + RenderCustomPass(renderGraph, hdCamera, colorBuffer, result, customPassCullingResults, CustomPassInjectionPoint.BeforeRendering, aovRequest, aovBuffers); RenderRayTracingPrepass(renderGraph, cullingResults, hdCamera, result.flagMaskBuffer, result.depthBuffer, false); @@ -249,7 +249,7 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph, DecalNormalPatch(renderGraph, hdCamera, ref result); // After Depth and Normals/roughness including decals - bool depthBufferModified = RenderCustomPass(renderGraph, hdCamera, colorBuffer, result.depthBuffer, result.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, aovRequest, aovBuffers); + bool depthBufferModified = RenderCustomPass(renderGraph, hdCamera, colorBuffer, result, customPassCullingResults, CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, aovRequest, aovBuffers); // If the depth was already copied in RenderDBuffer, we force the copy again because the custom pass modified the depth. if (depthBufferModified) @@ -282,6 +282,8 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph, // However if the generated HTile will be used for something else but SSR, this should be made NOT resolve only and // re-enabled in the shader. BuildCoarseStencilAndResolveIfNeeded(renderGraph, hdCamera, resolveOnly: true, ref result); + + RenderTransparencyOverdraw(renderGraph, result.depthBuffer, cullingResults, hdCamera); } return result; @@ -608,6 +610,8 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa passData.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, false), 1); if (passData.needMotionVectors) passData.motionVectorsBuffer = builder.UseColorBuffer(CreateMotionVectorBuffer(renderGraph, false, false), 2); + else + passData.motionVectorsBuffer = TextureHandle.nullHandle; passData.normalBufferMSAA = builder.ReadTexture(output.normalBuffer); passData.depthAsColorBufferMSAA = builder.ReadTexture(output.depthAsColor); @@ -624,8 +628,12 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa { data.depthResolveMaterial.SetTexture(HDShaderIDs._NormalTextureMS, data.normalBufferMSAA); data.depthResolveMaterial.SetTexture(HDShaderIDs._DepthTextureMS, data.depthAsColorBufferMSAA); - if (data.needMotionVectors) + if (passData.needMotionVectors) + { data.depthResolveMaterial.SetTexture(HDShaderIDs._MotionVectorTextureMS, data.motionVectorBufferMSAA); + } + + CoreUtils.SetKeyword(context.cmd, "_HAS_MOTION_VECTORS", data.needMotionVectors); context.cmd.DrawProcedural(Matrix4x4.identity, data.depthResolveMaterial, data.depthResolvePassIndex, MeshTopology.Triangles, 3, 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 42ca45fcefe..f5ede395e99 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 @@ -62,11 +62,11 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, ShadowResult shadowResult = new ShadowResult(); BuildGPULightListOutput gpuLightListOutput = new BuildGPULightListOutput(); - // TODO RENDERGRAPH: This should probably be moved somewhere else for the sake of consistency. - RenderTransparencyOverdraw(m_RenderGraph, prepassOutput.depthBuffer, cullingResults, hdCamera); - if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() && m_CurrentDebugDisplaySettings.IsFullScreenDebugPassEnabled()) { + // Stop Single Pass is after post process. + StartXRSinglePass(m_RenderGraph, hdCamera); + RenderFullScreenDebug(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer, cullingResults, hdCamera); } else if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled() || m_CurrentDebugDisplaySettings.IsMaterialValidationEnabled() || CoreUtils.IsSceneLightingDisabled(hdCamera.camera)) @@ -94,7 +94,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, { gpuLightListOutput = BuildGPULightList(m_RenderGraph, hdCamera, m_TileAndClusterData, m_TotalLightCount, ref m_ShaderVariablesLightListCB, prepassOutput.depthBuffer, prepassOutput.stencilBuffer, prepassOutput.gbuffer); - lightingBuffers.ambientOcclusionBuffer = m_AmbientOcclusionSystem.Render(m_RenderGraph, hdCamera, prepassOutput.depthPyramidTexture, prepassOutput.normalBuffer, prepassOutput.motionVectorsBuffer, m_FrameCount, m_DepthBufferMipChainInfo, m_ShaderVariablesRayTracingCB, rayCountTexture); + lightingBuffers.ambientOcclusionBuffer = m_AmbientOcclusionSystem.Render(m_RenderGraph, hdCamera, prepassOutput.depthPyramidTexture, prepassOutput.resolvedNormalBuffer, prepassOutput.resolvedMotionVectorsBuffer, m_FrameCount, m_DepthBufferMipChainInfo, m_ShaderVariablesRayTracingCB, rayCountTexture); // Should probably be inside the AO render function but since it's a separate class it's currently not super clean to do. PushFullScreenDebugTexture(m_RenderGraph, lightingBuffers.ambientOcclusionBuffer, FullScreenDebugMode.ScreenSpaceAmbientOcclusion); @@ -131,6 +131,13 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, lightingBuffers.ssgiLightingBuffer = m_RenderGraph.defaultResources.blackTextureXR; break; } + PushFullScreenDebugTexture(m_RenderGraph, lightingBuffers.ssgiLightingBuffer, FullScreenDebugMode.ScreenSpaceGlobalIllumination); + + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && GetRayTracingClusterState()) + { + HDRaytracingLightCluster lightCluster = RequestLightCluster(); + lightCluster.EvaluateClusterDebugView(m_RenderGraph, hdCamera, prepassOutput.depthBuffer, prepassOutput.depthPyramidTexture); + } lightingBuffers.screenspaceShadowBuffer = RenderScreenSpaceShadows(m_RenderGraph, hdCamera, prepassOutput, prepassOutput.depthBuffer, prepassOutput.normalBuffer, prepassOutput.motionVectorsBuffer, rayCountTexture); @@ -220,7 +227,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, // At this point, the color buffer has been filled by either debug views are regular rendering so we can push it here. var colorPickerTexture = PushColorPickerDebugTexture(m_RenderGraph, colorBuffer); - RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforePostProcess, aovRequest, aovBuffers); + RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforePostProcess, aovRequest, aovBuffers); if (aovRequest.isValid) { @@ -236,7 +243,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, } PushFullScreenExposureDebugTexture(m_RenderGraph, postProcessDest); - RenderCustomPass(m_RenderGraph, hdCamera, postProcessDest, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.AfterPostProcess, aovRequest, aovBuffers); + RenderCustomPass(m_RenderGraph, hdCamera, postProcessDest, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.AfterPostProcess, aovRequest, aovBuffers); CopyXRDepth(m_RenderGraph, hdCamera, prepassOutput.depthBuffer, backBuffer); @@ -260,11 +267,11 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, for (int viewIndex = 0; viewIndex < hdCamera.viewCount; ++viewIndex) { - BlitFinalCameraTexture(m_RenderGraph, hdCamera, postProcessDest, backBuffer, prepassOutput.resolvedMotionVectorsBuffer, prepassOutput.resolvedNormalBuffer, viewIndex); + BlitFinalCameraTexture(m_RenderGraph, hdCamera, postProcessDest, backBuffer, viewIndex); if (target.targetDepth != null) { - BlitFinalCameraTexture(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, m_RenderGraph.ImportTexture(target.targetDepth), prepassOutput.resolvedMotionVectorsBuffer, prepassOutput.resolvedNormalBuffer, viewIndex); + BlitFinalCameraTexture(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, m_RenderGraph.ImportTexture(target.targetDepth), viewIndex); } } @@ -302,7 +309,7 @@ class FinalBlitPassData public TextureHandle destination; } - void BlitFinalCameraTexture(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source, TextureHandle destination, TextureHandle motionVectors, TextureHandle normalBuffer, int viewIndex) + void BlitFinalCameraTexture(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle source, TextureHandle destination, int viewIndex) { using (var builder = renderGraph.AddRenderPass("Final Blit (Dev Build Only)", out var passData)) { @@ -434,6 +441,7 @@ class ForwardTransparentPassData : ForwardPassData public bool renderMotionVecForTransparent; public TextureHandle transparentSSRLighting; public TextureHandle volumetricLighting; + public TextureHandle depthPyramidTexture; } @@ -463,6 +471,16 @@ void PrepareCommonForwardPassData( RenderGraph renderGraph, HDShadowManager.ReadShadowResult(shadowResult, builder); } + static void BindGlobalLightListBuffers(ForwardPassData data, RenderGraphContext ctx) + { + ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vLightListGlobal, data.lightListBuffer); + // Next two are only for cluster rendering. PerTileLogBaseTweak is only when using depth buffer so can be invalid as well. + if (data.perVoxelOffset.IsValid()) + ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset); + if (data.perTileLogBaseTweak.IsValid()) + ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, data.perTileLogBaseTweak); + } + // Guidelines: In deferred by default there is no opaque in forward. However it is possible to force an opaque material to render in forward // by using the pass "ForwardOnly". In this case the .shader should not have "Forward" but only a "ForwardOnly" pass. // It must also have a "DepthForwardOnly" and no "DepthOnly" pass as forward material (either deferred or forward only rendering) have always a depth pass. @@ -521,6 +539,7 @@ void RenderForwardOpaque( RenderGraph renderGraph, for (int i = 0; i < data.renderTargetCount; ++i) mrt[i] = data.renderTarget[i]; + BindGlobalLightListBuffers(data, context); BindDBufferGlobalData(data.dbuffer, context); BindGlobalLightingBuffers(data.lightingBuffers, context.cmd); @@ -532,8 +551,7 @@ void RenderForwardOpaque( RenderGraph renderGraph, void RenderForwardTransparent( RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, - TextureHandle motionVectorBuffer, - TextureHandle depthBuffer, + in PrepassOutput prepassOutput, TextureHandle vtFeedbackBuffer, TextureHandle volumetricLighting, TextureHandle ssrLighting, @@ -563,7 +581,7 @@ void RenderForwardTransparent( RenderGraph renderGraph, using (var builder = renderGraph.AddRenderPass(passName, out var passData, ProfilingSampler.Get(profilingId))) { - PrepareCommonForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, depthBuffer, shadowResult); + PrepareCommonForwardPassData(renderGraph, builder, passData, false, hdCamera.frameSettings, PrepareForwardTransparentRendererList(cullResults, hdCamera, preRefractionPass), lightLists, prepassOutput.depthBuffer, shadowResult); // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered // decal datas count is 0 if no decals affect transparency @@ -571,6 +589,7 @@ void RenderForwardTransparent( RenderGraph renderGraph, passData.renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings); passData.volumetricLighting = builder.ReadTexture(volumetricLighting); passData.transparentSSRLighting = builder.ReadTexture(ssrLighting); + passData.depthPyramidTexture = builder.ReadTexture(prepassOutput.depthPyramidTexture); // We need to bind this for transparent materials doing stuff like soft particles etc. int index = 0; passData.renderTarget[index++] = builder.WriteTexture(colorBuffer); @@ -580,14 +599,17 @@ void RenderForwardTransparent( RenderGraph renderGraph, if (passData.renderMotionVecForTransparent) { - passData.renderTarget[index++] = builder.WriteTexture(motionVectorBuffer); + passData.renderTarget[index++] = builder.WriteTexture(prepassOutput.motionVectorsBuffer); } else { + bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); + // It doesn't really matter what gets bound here since the color mask state set will prevent this from ever being written to. However, we still need to bind something // to avoid warnings about unbound render targets. The following rendertarget could really be anything if renderVelocitiesForTransparent // Create a new target here should reuse existing already released one - passData.renderTarget[index++] = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_SRGB, name = "Transparency Velocity Dummy" }); + passData.renderTarget[index++] = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat = GraphicsFormat.R8G8B8A8_SRGB, bindTextureMS = msaa, enableMSAA = msaa, name = "Transparency Velocity Dummy" }); } passData.renderTargetCount = index; @@ -609,10 +631,11 @@ void RenderForwardTransparent( RenderGraph renderGraph, if (data.decalsEnabled) DecalSystem.instance.SetAtlas(context.cmd); // for clustered decals - context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset); - context.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, data.perTileLogBaseTweak); + BindGlobalLightListBuffers(data, context); + context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.transparentSSRLighting); context.cmd.SetGlobalTexture(HDShaderIDs._VBufferLighting, data.volumetricLighting); + context.cmd.SetGlobalTexture(HDShaderIDs._CameraDepthTexture, data.depthPyramidTexture); RenderForwardRendererList( data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, false, context.renderContext, context.cmd); }); @@ -846,10 +869,10 @@ TextureHandle RenderTransparency( RenderGraph renderGraph, // To allow users to fetch the current color buffer, we temporarily bind the camera color buffer SetGlobalColorForCustomPass(renderGraph, currentColorPyramid); - RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovBuffers); + RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovBuffers); // Render pre-refraction objects - RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, vtFeedbackBuffer, volumetricLighting, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true); + RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput, vtFeedbackBuffer, volumetricLighting, ssrLightingBuffer, null, lightLists, shadowResult, cullingResults, true); if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Refraction)) { @@ -858,10 +881,10 @@ TextureHandle RenderTransparency( RenderGraph renderGraph, } // We don't have access to the color pyramid with transparent if rough refraction is disabled - RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.normalBuffer, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovBuffers); + RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovBuffers); // Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects. - RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput.motionVectorsBuffer, prepassOutput.depthBuffer, vtFeedbackBuffer, volumetricLighting, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false); + RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, prepassOutput, vtFeedbackBuffer, volumetricLighting, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false); colorBuffer = ResolveMSAAColor(renderGraph, hdCamera, colorBuffer, m_NonMSAAColorBuffer); @@ -1360,7 +1383,8 @@ void RenderAccumulation(RenderGraph renderGraph, HDCamera hdCamera, TextureHandl TextureHandle history = renderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing) ?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1)); - passData.parameters = PrepareRenderAccumulationParameters(hdCamera, needExposure); + bool inputFromRadianceTexture = !inputTexture.Equals(outputTexture); + passData.parameters = PrepareRenderAccumulationParameters(hdCamera, needExposure, inputFromRadianceTexture); passData.input = builder.ReadTexture(inputTexture); passData.output = builder.WriteTexture(outputTexture); passData.history = builder.WriteTexture(history); @@ -1416,8 +1440,7 @@ void RenderGizmos(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colo bool RenderCustomPass( RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, - TextureHandle depthBuffer, - TextureHandle normalBuffer, + in PrepassOutput prepassOutput, CullingResults cullingResults, CustomPassInjectionPoint injectionPoint, AOVRequestData aovRequest, @@ -1449,8 +1472,9 @@ bool RenderCustomPass( RenderGraph renderGraph, // Render Graph Specific textures colorBufferRG = colorBuffer, nonMSAAColorBufferRG = m_NonMSAAColorBuffer, - depthBufferRG = depthBuffer, - normalBufferRG = normalBuffer, + depthBufferRG = prepassOutput.depthBuffer, + normalBufferRG = prepassOutput.resolvedNormalBuffer, + motionVectorBufferRG = prepassOutput.resolvedMotionVectorsBuffer }; executed |= customPass.Execute(renderGraph, hdCamera, cullingResults, customPassTargets); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs index 7ccb59ce2d3..ba31930f9e3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs @@ -69,6 +69,13 @@ void RenderSubsurfaceScattering(RenderGraph renderGraph, HDCamera hdCamera, Text new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.B10G11R11_UFloatPack32, enableRandomWrite = true, clearBuffer = true, clearColor = Color.clear, name = "SSSCameraFiltering" }); } + else + { + // We need to set this as otherwise it will still be using an handle that is potentially coming from another rendergraph execution. + // For example if we have two cameras, if NeedTemporarySubsurfaceBuffer() is false, but one camera has MSAA and one hasn't, only one camera + // will have passData.parameters.needTemporaryBuffer true and the other that doesn't, without explicit setting to null handle will try to use handle of the other camera. + passData.cameraFilteringBuffer = TextureHandle.nullHandle; + } builder.SetRenderFunc( (SubsurfaceScaterringPassData data, RenderGraphContext context) => diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 6585102ac51..c92bb76f752 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -175,6 +175,7 @@ internal static Volume GetOrCreateDefaultVolume() Material m_Blit; Material m_BlitTexArray; Material m_BlitTexArraySingleSlice; + Material m_BlitColorAndDepth; MaterialPropertyBlock m_BlitPropertyBlock = new MaterialPropertyBlock(); RenderTargetIdentifier[] m_MRTCache2 = new RenderTargetIdentifier[2]; @@ -327,6 +328,7 @@ internal int GetMaxScreenSpaceShadows() string m_ForwardPassProfileName; internal Material GetBlitMaterial(bool useTexArray, bool singleSlice) { return useTexArray ? (singleSlice ? m_BlitTexArraySingleSlice : m_BlitTexArray) : m_Blit; } + internal Material GetBlitColorAndDepthMaterial() { return m_BlitColorAndDepth; } ComputeBuffer m_DepthPyramidMipLevelOffsetsBuffer = null; @@ -346,9 +348,9 @@ internal bool showCascade } // RENDER GRAPH - internal static bool enableRenderGraphTests { get => Array.Exists(Environment.GetCommandLineArgs(), arg => arg == "-rendergraph-tests"); } - RenderGraph m_RenderGraph; - bool m_EnableRenderGraph; + internal static bool enableNonRenderGraphTests { get => Array.Exists(Environment.GetCommandLineArgs(), arg => arg == "-non-rendergraph-tests"); } + RenderGraph m_RenderGraph = new RenderGraph(); + bool m_EnableRenderGraph = true; // MSAA resolve materials Material m_ColorResolveMaterial = null; @@ -383,6 +385,11 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau SetRenderingFeatures(); + // Initialize lod settings with the default frame settings. This will pull LoD values from the current quality level HDRP asset if necessary. + // This will make the LoD Group UI consistent with the scene view camera like it is for builtin pipeline. + QualitySettings.lodBias = m_Asset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera).GetResolvedLODBias(m_Asset); + QualitySettings.maximumLODLevel = m_Asset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera).GetResolvedMaximumLODLevel(m_Asset); + // The first thing we need to do is to set the defines that depend on the render pipeline settings m_RayTracingSupported = GatherRayTracingSupport(m_Asset.currentPlatformRenderPipelineSettings); @@ -534,8 +541,6 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau m_DepthPyramidMipLevelOffsetsBuffer = new ComputeBuffer(15, sizeof(int) * 2); - InitializeRenderTextures(); - // TODO RENDERGRAPH: Moved those out of InitializeRenderTexture as they are still needed in render graph and would be deallocated otherwise when switching it on. m_CustomPassColorBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer")); m_CustomPassDepthBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R32_UInt, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: DepthBits.Depth32)); @@ -583,8 +588,8 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau InitializeProbeVolumes(); CustomPassUtils.Initialize(); - if (enableRenderGraphTests) - EnableRenderGraph(true); + if (enableNonRenderGraphTests) + EnableRenderGraph(false); } #if UNITY_EDITOR @@ -754,6 +759,25 @@ void InitializeRenderTextures() m_OpaqueAtmosphericScatteringMSAABuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetColorBufferFormat(), bindTextureMS: true, enableMSAA: true, useDynamicScale: true, name: "OpaqueAtmosphericScatteringMSAA"); m_CameraSssDiffuseLightingMSAABuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetColorBufferFormat(), bindTextureMS: true, enableMSAA: true, useDynamicScale: true, name: "CameraSSSDiffuseLightingMSAA"); } + + if (m_RayTracingSupported) + { + m_RaytracingGBufferManager.CreateBuffers(); + m_RayCountManager.InitializeNonRenderGraphResources(); + + if (m_Asset.currentPlatformRenderPipelineSettings.supportSSGI) + { + m_IndirectDiffuseBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer0"); + m_IndirectDiffuseBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer1"); + m_IndirectDiffuseBuffer2 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer2"); + m_IndirectDiffuseBuffer3 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseBuffer3"); + m_IndirectDiffuseHitPointBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IndirectDiffuseHitBuffer"); + } + + m_RayTracingLightCluster.InitializeNonRenderGraphResources(); + + m_FlagMaskTextureRT = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R8_SNorm, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "FlagMaskTexture"); + } } void GetOrCreateDebugTextures() @@ -812,6 +836,29 @@ void DestroyRenderTextures() m_DebugColorPickerBuffer = null; m_DebugFullScreenTempBuffer = null; m_IntermediateAfterPostProcessBuffer = null; + + if (m_RayTracingSupported) + { + m_RaytracingGBufferManager.DestroyBuffers(); + m_RayCountManager.CleanupNonRenderGraphResources(); + + if (m_IndirectDiffuseBuffer0 != null) + RTHandles.Release(m_IndirectDiffuseBuffer0); + if (m_IndirectDiffuseBuffer1 != null) + RTHandles.Release(m_IndirectDiffuseBuffer1); + if (m_IndirectDiffuseBuffer2 != null) + RTHandles.Release(m_IndirectDiffuseBuffer2); + if (m_IndirectDiffuseBuffer3 != null) + RTHandles.Release(m_IndirectDiffuseBuffer3); + if (m_IndirectDiffuseHitPointBuffer != null) + RTHandles.Release(m_IndirectDiffuseHitPointBuffer); + + m_RayTracingLightCluster.CleanupNonRenderGraphResources(); + + RTHandles.Release(m_FlagMaskTextureRT); + + RaytracingManagerCleanupNonRenderGraphResources(); + } } void SetRenderingFeatures() @@ -1014,6 +1061,7 @@ void InitializeNonRenderGraphResources() m_AmbientOcclusionSystem.InitializeNonRenderGraphResources(); m_PostProcessSystem.InitializeNonRenderGraphResources(asset); s_lightVolumes.InitializeNonRenderGraphResources(); + ScreenSpaceShadowInitializeNonRenderGraphResources(); // Reset resolution dependent buffers. Tile, Coarse stencil etc... m_MaxCameraWidth = m_MaxCameraHeight = m_MaxViewCount = 1; @@ -1029,6 +1077,7 @@ void CleanupNonRenderGraphResources() LightLoopCleanupNonRenderGraphResources(); m_SharedRTManager.DisposeFullScreenDebugBuffer(); m_SharedRTManager.DisposeCoarseStencilBuffer(); + ScreenSpaceShadowCleanupNonRenderGraphResources(); } void InitializeDebugMaterials() @@ -1041,6 +1090,7 @@ void InitializeDebugMaterials() m_DebugColorPicker = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugColorPickerPS); m_DebugExposure = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugExposurePS); m_Blit = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitPS); + m_BlitColorAndDepth = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitColorAndDepthPS); m_ErrorMaterial = CoreUtils.CreateEngineMaterial("Hidden/InternalErrorShader"); // With texture array enabled, we still need the normal blit version for other systems like atlas @@ -1094,12 +1144,13 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); + if (!m_EnableRenderGraph) + CleanupNonRenderGraphResources(); + ReleaseScreenSpaceShadows(); - ReleaseScreenSpaceGlobalIllumination(); if (m_RayTracingSupported) { - ReleaseRecursiveRenderer(); ReleaseRayTracingDeferred(); ReleaseRayTracedIndirectDiffuse(); ReleaseRayTracedReflections(); @@ -1151,15 +1202,12 @@ protected override void Dispose(bool disposing) } m_PostProcessSystem.Cleanup(); - m_AmbientOcclusionSystem.Cleanup(); m_BlueNoise.Cleanup(); HDCamera.ClearAll(); m_MipGenerator.Release(); - DestroyRenderTextures(); - if (m_CustomPassColorBuffer.IsValueCreated) RTHandles.Release(m_CustomPassColorBuffer.Value); if (m_CustomPassDepthBuffer.IsValueCreated) @@ -2251,7 +2299,7 @@ ref _cullingResults } if (m_EnableRenderGraph) - m_RenderGraph.PurgeUnusedResources(); + m_RenderGraph.EndFrame(); m_XRSystem.ReleaseFrame(); UnityEngine.Rendering.RenderPipeline.EndFrameRendering(renderContext, cameras); } @@ -4035,8 +4083,16 @@ void RenderDebugViewMaterial(CullingResults cull, HDCamera hdCamera, ScriptableR { // When rendering debug material we shouldn't rely on a depth prepass for optimizing the alpha clip test. As it is control on the material inspector side // we must override the state here. - CoreUtils.SetRenderTarget(cmd, m_CameraColorBuffer, m_SharedRTManager.GetDepthStencilBuffer(), ClearFlag.All, Color.clear); + + // [case 1273223] When the camera is stacked on top of another one, we need to clear the debug view RT using the data from the previous camera in the stack + var clearColorTexture = Compositor.CompositionManager.GetClearTextureForStackedCamera(hdCamera); // returns null if is not a stacked camera + var clearDepthTexture = Compositor.CompositionManager.GetClearDepthForStackedCamera(hdCamera); // returns null if is not a stacked camera + if (clearColorTexture) + { + HDUtils.BlitColorAndDepth(cmd, clearColorTexture, clearDepthTexture, new Vector4(1, 1, 0, 0), 0, !hdCamera.clearDepth); + } + // Render Opaque forward var rendererListOpaque = RendererList.Create(CreateOpaqueRendererListDesc(cull, hdCamera.camera, m_AllForwardOpaquePassNames, m_CurrentRendererConfigurationBakedLighting, stateBlock: m_DepthStateOpaque)); DrawOpaqueRendererList(renderContext, cmd, hdCamera.frameSettings, rendererListOpaque); @@ -5120,6 +5176,9 @@ struct DebugParameters public DebugDisplaySettings debugDisplaySettings; public HDCamera hdCamera; + // Overlay + public DebugOverlay debugOverlay; + // Full screen debug public bool resolveFullScreenDebug; public Material debugFullScreenMaterial; @@ -5135,6 +5194,7 @@ struct DebugParameters // Lighting public LightLoopDebugOverlayParameters lightingOverlayParameters; + public ProbeVolumeDebugOverlayParameters probeVolumeOverlayParameters; // Color picker public bool colorPickerEnabled; @@ -5160,6 +5220,7 @@ DebugParameters PrepareDebugParameters(HDCamera hdCamera, HDUtils.PackedMipChain parameters.skyReflectionTexture = m_SkyManager.GetSkyReflection(hdCamera); parameters.debugLatlongMaterial = m_DebugDisplayLatlong; parameters.lightingOverlayParameters = PrepareLightLoopDebugOverlayParameters(); + parameters.probeVolumeOverlayParameters = PrepareProbeVolumeOverlayParameters(m_CurrentDebugDisplaySettings.data.lightingDebugSettings); parameters.rayTracingSupported = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing); parameters.rayCountManager = m_RayCountManager; @@ -5170,6 +5231,11 @@ DebugParameters PrepareDebugParameters(HDCamera hdCamera, HDUtils.PackedMipChain parameters.exposureDebugEnabled = NeedExposureDebugMode(parameters.debugDisplaySettings); parameters.debugExposureMaterial = m_DebugExposure; + float overlayRatio = m_CurrentDebugDisplaySettings.data.debugOverlayRatio; + int overlaySize = (int)(Math.Min(hdCamera.actualHeight, hdCamera.actualWidth) * overlayRatio); + m_DebugOverlay.StartOverlay(HDUtils.GetRuntimeDebugPanelWidth(hdCamera), hdCamera.actualHeight - overlaySize, overlaySize, hdCamera.actualWidth); + parameters.debugOverlay = m_DebugOverlay; + return parameters; } @@ -5328,25 +5394,22 @@ static void RenderExposureDebug(in DebugParameters parameters, HDUtils.DrawFullScreen(cmd, parameters.debugExposureMaterial, output, null, passIndex); } - static void RenderSkyReflectionOverlay(in DebugParameters debugParameters, CommandBuffer cmd, MaterialPropertyBlock mpb, ref float x, ref float y, float overlaySize) + static void RenderSkyReflectionOverlay(in DebugParameters debugParameters, CommandBuffer cmd, MaterialPropertyBlock mpb) { var lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; - if (lightingDebug.displaySkyReflection) - { - mpb.SetTexture(HDShaderIDs._InputCubemap, debugParameters.skyReflectionTexture); - mpb.SetFloat(HDShaderIDs._Mipmap, lightingDebug.skyReflectionMipmap); - mpb.SetFloat(HDShaderIDs._ApplyExposure, 1.0f); - mpb.SetFloat(HDShaderIDs._SliceIndex, lightingDebug.cubeArraySliceIndex); - cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); - cmd.DrawProcedural(Matrix4x4.identity, debugParameters.debugLatlongMaterial, 0, MeshTopology.Triangles, 3, 1, mpb); - HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, debugParameters.hdCamera); - } + + debugParameters.debugOverlay.SetViewport(cmd); + mpb.SetTexture(HDShaderIDs._InputCubemap, debugParameters.skyReflectionTexture); + mpb.SetFloat(HDShaderIDs._Mipmap, lightingDebug.skyReflectionMipmap); + mpb.SetFloat(HDShaderIDs._ApplyExposure, 1.0f); + mpb.SetFloat(HDShaderIDs._SliceIndex, lightingDebug.cubeArraySliceIndex); + cmd.DrawProcedural(Matrix4x4.identity, debugParameters.debugLatlongMaterial, 0, MeshTopology.Triangles, 3, 1, mpb); + debugParameters.debugOverlay.Next(); } - static void RenderRayCountOverlay(in DebugParameters debugParameters, CommandBuffer cmd, ref float x, ref float y, float overlaySize) + static void RenderRayCountOverlay(in DebugParameters debugParameters, CommandBuffer cmd) { - if (debugParameters.rayTracingSupported) - debugParameters.rayCountManager.EvaluateRayCount(cmd, debugParameters.hdCamera); + debugParameters.rayCountManager.EvaluateRayCount(cmd, debugParameters.hdCamera); } void RenderDebug(HDCamera hdCamera, CommandBuffer cmd, CullingResults cullResults) @@ -5399,26 +5462,17 @@ void RenderDebug(HDCamera hdCamera, CommandBuffer cmd, CullingResults cullResult s_lightVolumes.RenderLightVolumes(cmd, hdCamera, cullResults, lightingDebug, m_IntermediateAfterPostProcessBuffer); } - // Then overlays - HDUtils.ResetOverlay(); - float debugPanelWidth = HDUtils.GetRuntimeDebugPanelWidth(debugParams.hdCamera); - float x = 0.0f; - float overlayRatio = debugParams.debugDisplaySettings.data.debugOverlayRatio; - float overlaySize = Math.Min(debugParams.hdCamera.actualHeight, debugParams.hdCamera.actualWidth - debugPanelWidth) * overlayRatio; - float y = debugParams.hdCamera.actualHeight - overlaySize; - - // Add the width of the debug display if enabled on the camera - x += debugPanelWidth; - - RenderSkyReflectionOverlay(debugParams, cmd, m_SharedPropertyBlock, ref x, ref y, overlaySize); - RenderRayCountOverlay(debugParams, cmd, ref x, ref y, overlaySize); - RenderLightLoopDebugOverlay(debugParams, cmd, ref x, ref y, overlaySize, m_TileAndClusterData.tileList, m_TileAndClusterData.lightList, m_TileAndClusterData.perVoxelLightLists, m_TileAndClusterData.dispatchIndirectBuffer, m_SharedRTManager.GetDepthTexture()); - RenderProbeVolumeDebugOverlay(debugParams, cmd, ref x, ref y, overlaySize, m_DebugDisplayProbeVolumeMaterial); // TODO(Nicholas): renders as a black square in the upper right. + if (lightingDebug.displaySkyReflection) + RenderSkyReflectionOverlay(debugParams, cmd, m_SharedPropertyBlock); + if (debugParams.rayTracingSupported) + RenderRayCountOverlay(debugParams, cmd); + RenderLightLoopDebugOverlay(debugParams, cmd, m_TileAndClusterData.tileList, m_TileAndClusterData.lightList, m_TileAndClusterData.perVoxelLightLists, m_TileAndClusterData.dispatchIndirectBuffer, m_SharedRTManager.GetDepthTexture()); + RenderProbeVolumeDebugOverlay(debugParams, cmd); // TODO(Nicholas): renders as a black square in the upper right. HDShadowManager.ShadowDebugAtlasTextures atlases = debugParams.lightingOverlayParameters.shadowManager.GetDebugAtlasTextures(); - RenderShadowsDebugOverlay(debugParams, atlases, cmd, ref x, ref y, overlaySize, m_SharedPropertyBlock); + RenderShadowsDebugOverlay(debugParams, atlases, cmd, m_SharedPropertyBlock); - DecalSystem.instance.RenderDebugOverlay(debugParams.hdCamera, cmd, debugParams.debugDisplaySettings, ref x, ref y, overlaySize, debugParams.hdCamera.actualWidth); + DecalSystem.instance.RenderDebugOverlay(debugParams.hdCamera, cmd, debugParams.debugDisplaySettings, debugParams.debugOverlay); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index e0c8883b760..ece081b7e85 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -127,7 +127,7 @@ static class HDShaderIDs public static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer"); public static readonly int _LightListToClear = Shader.PropertyToID("_LightListToClear"); - public static readonly int _LightListEntries = Shader.PropertyToID("_LightListEntries"); + public static readonly int _LightListEntriesAndOffset = Shader.PropertyToID("_LightListEntriesAndOffset"); public static readonly int _ViewTilesFlags = Shader.PropertyToID("_ViewTilesFlags"); public static readonly int _ClusterDebugMode = Shader.PropertyToID("_ClusterDebugMode"); @@ -567,6 +567,7 @@ static class HDShaderIDs public static readonly int _RaytracedColorShadowIntegration = Shader.PropertyToID("_RaytracedColorShadowIntegration"); public static readonly int _DirectionalLightAngle = Shader.PropertyToID("_DirectionalLightAngle"); + public static readonly int _DirectionalMaxRayLength = Shader.PropertyToID("_DirectionalMaxRayLength"); public static readonly int _DirectionalLightDirection = Shader.PropertyToID("_DirectionalLightDirection"); public static readonly int _SphereLightPosition = Shader.PropertyToID("_SphereLightPosition"); public static readonly int _SphereLightRadius = Shader.PropertyToID("_SphereLightRadius"); @@ -713,6 +714,8 @@ static class HDShaderIDs public static readonly int _ChromaSpectralLut = Shader.PropertyToID("_ChromaSpectralLut"); public static readonly int _ChromaParams = Shader.PropertyToID("_ChromaParams"); + public static readonly int _AlphaScaleBias = Shader.PropertyToID("_AlphaScaleBias"); + public static readonly int _VignetteParams1 = Shader.PropertyToID("_VignetteParams1"); public static readonly int _VignetteParams2 = Shader.PropertyToID("_VignetteParams2"); public static readonly int _VignetteColor = Shader.PropertyToID("_VignetteColor"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index 84b535cd9a7..b6e6e19f2cc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -80,8 +80,8 @@ void InitPathTracing() #endif // UNITY_EDITOR m_RadianceTexture = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R32G32B32A32_SFloat, dimension: TextureXR.dimension, - enableRandomWrite: true, useMipMap: false, autoGenerateMips: false, - name: "PathTracingFrameBuffer"); + enableRandomWrite: true, useMipMap: false, autoGenerateMips: false, + name: "PathTracingFrameBuffer"); } void ReleasePathTracing() 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 fb03efd30c0..a4ea5493241 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 @@ -63,13 +63,33 @@ bool IsPointLightActive(LightData lightData, float3 position, float3 normal) if (lightTangentDist * abs(lightTangentDist) > lightData.size.x) return false; - // Offset the light position towards the back, to account for the radius, - // then check whether we are still within the dilated cone angle - float sqSinAngle = 1.0 - Sq(lightData.angleOffset / lightData.angleScale); - float3 lightOffset = sqrt(lightData.size.x / sqSinAngle) * lightData.forward; - float lightCos = dot(normalize(lightVec + lightOffset), lightData.forward); + // If this is an omni-directional point light, we're done + if (lightData.lightType == GPULIGHTTYPE_POINT) + return true; + + // Check that we are on the right side of the light plane + float z = dot(lightVec, lightData.forward); + if (z < 0.0) + return false; + + if (lightData.lightType == GPULIGHTTYPE_SPOT) + { + // Offset the light position towards the back, to account for the radius, + // 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); + + 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)); - return lightCos * lightData.angleScale + lightData.angleOffset > 0.0; + return (lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) ? + x < 1 && y < 1 : // BOX + x < z && y < z; // PYRAMID } bool IsDistantLightActive(DirectionalLightData lightData, float3 normal) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingAmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingAmbientOcclusion.cs index 281b0da6da0..9bf44e6bec8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingAmbientOcclusion.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingAmbientOcclusion.cs @@ -34,16 +34,21 @@ public void Init(HDRenderPipeline renderPipeline) // Grab the kernels we need m_RTAOApplyIntensityKernel = m_PipelineRayTracingResources.aoRaytracingCS.FindKernel("RTAOApplyIntensity"); + } + public void InitializeNonRenderGraphResources() + { // Allocate the intermediate textures m_AOIntermediateBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer0"); m_AOIntermediateBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer1"); } - public void Release() + public void CleanupNonRenderGraphResources() { RTHandles.Release(m_AOIntermediateBuffer1); RTHandles.Release(m_AOIntermediateBuffer0); + m_AOIntermediateBuffer0 = null; + m_AOIntermediateBuffer1 = null; } static RTHandle AmbientOcclusionHistoryBufferAllocatorFunction(string viewName, int frameIndex, RTHandleSystem rtHandleSystem) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingDeferredLightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingDeferredLightLoop.cs index a68667da4cd..d7a7b3ee151 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingDeferredLightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingDeferredLightLoop.cs @@ -80,7 +80,6 @@ void InitRaytracingDeferred() m_RayBinSizeResult = new ComputeBuffer(1, sizeof(uint)); m_RaytracingGBufferManager = new GBufferManager(asset, m_DeferredMaterial); - m_RaytracingGBufferManager.CreateBuffers(); } void ReleaseRayTracingDeferred() diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs index 38b910ba49d..0bff199344b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingLightCluster.cs @@ -1,5 +1,6 @@ using UnityEngine.Experimental.Rendering; using System.Collections.Generic; +using UnityEngine.Experimental.Rendering.RenderGraphModule; namespace UnityEngine.Rendering.HighDefinition { @@ -14,7 +15,7 @@ struct LightVolume public uint lightIndex; } - internal class HDRaytracingLightCluster + class HDRaytracingLightCluster { // External data RenderPipelineResources m_RenderPipelineResources = null; @@ -93,9 +94,6 @@ public void Initialize(HDRenderPipeline renderPipeline) // Keep track of the render pipeline m_RenderPipeline = renderPipeline; - // Texture used to output debug information - m_DebugLightClusterTexture = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "DebugLightClusterTexture"); - // Pre allocate the cluster with a dummy size m_LightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData))); m_EnvLightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData))); @@ -111,8 +109,6 @@ public void Initialize(HDRenderPipeline renderPipeline) public void ReleaseResources() { - m_DebugLightClusterTexture.Release(); - if (m_LightVolumeGPUArray != null) { CoreUtils.SafeRelease(m_LightVolumeGPUArray); @@ -150,6 +146,18 @@ public void ReleaseResources() } } + public void InitializeNonRenderGraphResources() + { + // Texture used to output debug information + m_DebugLightClusterTexture = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "DebugLightClusterTexture"); + } + + public void CleanupNonRenderGraphResources() + { + m_DebugLightClusterTexture.Release(); + m_DebugLightClusterTexture = null; + } + void ResizeClusterBuffer(int bufferSize) { // Release the previous buffer @@ -300,10 +308,10 @@ void BuildGPULightVolumes(HDRayTracingLights rayTracingLights) // Reserve space in the cookie atlas m_RenderPipeline.ReserveCookieAtlasTexture(currentLight, light, currentLight.type); - + // Grab the light range float lightRange = light.range; - + if (currentLight.type != HDLightType.Area) { m_LightVolumesCPUArray[realIndex].range = new Vector3(lightRange, lightRange, lightRange); @@ -519,7 +527,7 @@ void BuildLightData(CommandBuffer cmd, HDCamera hdCamera, HDRayTracingLights ray processedData.lightDistanceFade = HDUtils.ComputeLinearDistanceFade(processedData.distanceToCamera, additionalLightData.fadeDistance); processedData.isBakedShadowMask = HDRenderPipeline.IsBakedShadowMaskLight(lightComponent); - // Build a visible light + // Build a visible light Color finalColor = lightComponent.color.linear * lightComponent.intensity; if (additionalLightData.useColorTemperature) finalColor *= Mathf.CorrelatedColorTemperatureToRGB(lightComponent.colorTemperature); @@ -539,7 +547,7 @@ void BuildLightData(CommandBuffer cmd, HDCamera hdCamera, HDRayTracingLights ray Vector3 lightDimensions = new Vector3(0.0f, 0.0f, 0.0f); // Use the shared code to build the light data - m_RenderPipeline.GetLightData(cmd, hdCamera, hdShadowSettings, visibleLight, lightComponent, in processedData, + m_RenderPipeline.GetLightData(cmd, hdCamera, hdShadowSettings, visibleLight, lightComponent, in processedData, shadowIndex, contactShadowScalableSetting, isRasterization: false, ref lightDimensions, ref screenSpaceShadowIndex, ref screenSpaceChannelSlot, ref lightData); // We make the light position camera-relative as late as possible in order @@ -599,47 +607,124 @@ void BuildEnvLightData(CommandBuffer cmd, HDCamera hdCamera, HDRayTracingLights m_EnvLightDataGPUArray.SetData(m_EnvLightDataCPUArray); } - public void EvaluateClusterDebugView(CommandBuffer cmd, HDCamera hdCamera) + public struct LightClusterDebugParameters { - ComputeShader lightClusterDebugCS = m_RenderPipelineRayTracingResources.lightClusterDebugCS; - if (lightClusterDebugCS == null) return; + public int texWidth; + public int texHeight; + public int lightClusterDebugKernel; + public Vector3 clusterCellSize; + public Material debugMaterial; + public ComputeBuffer lightCluster; + public MaterialPropertyBlock debugMaterialProperties; + public ComputeShader lightClusterDebugCS; + } - // Bind the output texture - CoreUtils.SetRenderTarget(cmd, m_DebugLightClusterTexture, m_RenderPipeline.sharedRTManager.GetDepthStencilBuffer(), clearFlag: ClearFlag.Color, clearColor: Color.black); + LightClusterDebugParameters PrepareLightClusterDebugParameters(HDCamera hdCamera) + { + LightClusterDebugParameters parameters = new LightClusterDebugParameters(); + parameters.texWidth = hdCamera.actualWidth; + parameters.texHeight = hdCamera.actualHeight; + parameters.clusterCellSize = clusterCellSize; + parameters.lightCluster = m_LightCluster; + parameters.lightClusterDebugCS = m_RenderPipelineRayTracingResources.lightClusterDebugCS; + parameters.lightClusterDebugKernel = parameters.lightClusterDebugCS.FindKernel("DebugLightCluster"); + parameters.debugMaterial = m_DebugMaterial; + parameters.debugMaterialProperties = m_DebugMaterialProperties; + return parameters; + } + + public struct LightClusterDebugResources + { + public RTHandle depthStencilBuffer; + public RTHandle depthTexture; + public RTHandle debugLightClusterTexture; + } + + LightClusterDebugResources PrepareLightClusterDebugResources(RTHandle outputDebugLightBuffer) + { + LightClusterDebugResources resources = new LightClusterDebugResources(); + resources.debugLightClusterTexture = outputDebugLightBuffer; + resources.depthTexture = m_RenderPipeline.sharedRTManager.GetDepthTexture(); + resources.depthStencilBuffer = m_RenderPipeline.sharedRTManager.GetDepthStencilBuffer(); + return resources; + } - // Grab the kernel - int m_LightClusterDebugKernel = lightClusterDebugCS.FindKernel("DebugLightCluster"); + static public void ExecuteLightClusterDebug(CommandBuffer cmd, LightClusterDebugParameters parameters, LightClusterDebugResources resources) + { + // Bind the output texture + CoreUtils.SetRenderTarget(cmd, resources.debugLightClusterTexture, resources.depthStencilBuffer, clearFlag: ClearFlag.Color, clearColor: Color.black); // Inject all the parameters to the debug compute - cmd.SetComputeBufferParam(lightClusterDebugCS, m_LightClusterDebugKernel, HDShaderIDs._RaytracingLightCluster, m_LightCluster); - cmd.SetComputeVectorParam(lightClusterDebugCS, _ClusterCellSize, clusterCellSize); - cmd.SetComputeTextureParam(lightClusterDebugCS, m_LightClusterDebugKernel, HDShaderIDs._CameraDepthTexture, m_RenderPipeline.sharedRTManager.GetDepthStencilBuffer()); + cmd.SetComputeBufferParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, HDShaderIDs._RaytracingLightCluster, parameters.lightCluster); + cmd.SetComputeVectorParam(parameters.lightClusterDebugCS, _ClusterCellSize, parameters.clusterCellSize); + cmd.SetComputeTextureParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, HDShaderIDs._CameraDepthTexture, resources.depthStencilBuffer); // Target output texture - cmd.SetComputeTextureParam(lightClusterDebugCS, m_LightClusterDebugKernel, _DebutLightClusterTexture, m_DebugLightClusterTexture); - - // Texture dimensions - int texWidth = hdCamera.actualWidth; - int texHeight = hdCamera.actualHeight; + cmd.SetComputeTextureParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, _DebutLightClusterTexture, resources.debugLightClusterTexture); // Dispatch the compute int lightVolumesTileSize = 8; - int numTilesX = (texWidth + (lightVolumesTileSize - 1)) / lightVolumesTileSize; - int numTilesY = (texHeight + (lightVolumesTileSize - 1)) / lightVolumesTileSize; + int numTilesX = (parameters.texWidth + (lightVolumesTileSize - 1)) / lightVolumesTileSize; + int numTilesY = (parameters.texHeight + (lightVolumesTileSize - 1)) / lightVolumesTileSize; - cmd.DispatchCompute(lightClusterDebugCS, m_LightClusterDebugKernel, numTilesX, numTilesY, 1); + cmd.DispatchCompute(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, numTilesX, numTilesY, 1); // Bind the parameters - m_DebugMaterialProperties.SetBuffer(HDShaderIDs._RaytracingLightCluster, m_LightCluster); - m_DebugMaterialProperties.SetVector(_ClusterCellSize, clusterCellSize); - m_DebugMaterialProperties.SetTexture(HDShaderIDs._CameraDepthTexture, m_RenderPipeline.sharedRTManager.GetDepthTexture()); + parameters.debugMaterialProperties.SetBuffer(HDShaderIDs._RaytracingLightCluster, parameters.lightCluster); + parameters.debugMaterialProperties.SetVector(_ClusterCellSize, parameters.clusterCellSize); + parameters.debugMaterialProperties.SetTexture(HDShaderIDs._CameraDepthTexture, resources.depthTexture); // Draw the faces - cmd.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, 1, MeshTopology.Lines, 48, 64 * 64 * 32, m_DebugMaterialProperties); - cmd.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, 0, MeshTopology.Triangles, 36, 64 * 64 * 32, m_DebugMaterialProperties); + cmd.DrawProcedural(Matrix4x4.identity, parameters.debugMaterial, 1, MeshTopology.Lines, 48, 64 * 64 * 32, parameters.debugMaterialProperties); + cmd.DrawProcedural(Matrix4x4.identity, parameters.debugMaterial, 0, MeshTopology.Triangles, 36, 64 * 64 * 32, parameters.debugMaterialProperties); + } + + public void EvaluateClusterDebugView(CommandBuffer cmd, HDCamera hdCamera) + { + LightClusterDebugParameters parameters = PrepareLightClusterDebugParameters(hdCamera); + LightClusterDebugResources resources = PrepareLightClusterDebugResources(m_DebugLightClusterTexture); + ExecuteLightClusterDebug(cmd, parameters, resources); // Bind the result - (RenderPipelineManager.currentPipeline as HDRenderPipeline).PushFullScreenDebugTexture(hdCamera, cmd, m_DebugLightClusterTexture, FullScreenDebugMode.LightCluster); + m_RenderPipeline.PushFullScreenDebugTexture(hdCamera, cmd, m_DebugLightClusterTexture, FullScreenDebugMode.LightCluster); + } + + class LightClusterDebugPassData + { + public LightClusterDebugParameters parameters; + public TextureHandle depthStencilBuffer; + public TextureHandle depthPyramid; + public TextureHandle outputBuffer; + } + + public void EvaluateClusterDebugView(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle depthStencilBuffer, TextureHandle depthPyramid) + { + TextureHandle debugTexture; + using (var builder = renderGraph.AddRenderPass("Debug Texture for the Light Cluster", out var passData, ProfilingSampler.Get(HDProfileId.RaytracingDebugCluster))) + { + builder.EnableAsyncCompute(false); + + passData.parameters = PrepareLightClusterDebugParameters(hdCamera); + passData.depthStencilBuffer = builder.UseDepthBuffer(depthStencilBuffer, DepthAccess.Read); + passData.depthPyramid = builder.ReadTexture(depthStencilBuffer); + passData.outputBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite = true, name = "Light Cluster Debug Texture" })); + + builder.SetRenderFunc( + (LightClusterDebugPassData data, RenderGraphContext ctx) => + { + // We need to fill the structure that holds the various resources + LightClusterDebugResources resources = new LightClusterDebugResources(); + resources.depthStencilBuffer = data.depthStencilBuffer; + resources.depthTexture = data.depthPyramid; + resources.debugLightClusterTexture = data.outputBuffer; + ExecuteLightClusterDebug(ctx.cmd, data.parameters, resources); + }); + + debugTexture = passData.outputBuffer; + } + + m_RenderPipeline.PushFullScreenDebugTexture(renderGraph, debugTexture, FullScreenDebugMode.LightCluster); } public ComputeBuffer GetCluster() @@ -729,14 +814,14 @@ public void BuildLightClusterBuffer(CommandBuffer cmd, HDCamera hdCamera, HDRayT // If there is no lights to process or no environment not the shader is missing if (totalLightCount == 0 || rayTracingLights.lightCount == 0 || !m_RenderPipeline.GetRayTracingState()) return; - + // Cull the lights within the evaluated cluster range CullLights(cmd); // Build the light Cluster BuildLightCluster(hdCamera, cmd); } - + public void ReserveCookieAtlasSlots( HDRayTracingLights rayTracingLights) { for (int lightIdx = 0; lightIdx < rayTracingLights.hdLightArray.Count; ++lightIdx) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs index b499a4695ce..07007bbd047 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingManager.cs @@ -125,30 +125,6 @@ internal void InitRayTracingManager() internal void ReleaseRayTracingManager() { - if (m_RayTracingDistanceBuffer != null) - RTHandles.Release(m_RayTracingDistanceBuffer); - if (m_RayTracingDirectionBuffer != null) - RTHandles.Release(m_RayTracingDirectionBuffer); - - if (m_RayTracingIntermediateBufferR0 != null) - RTHandles.Release(m_RayTracingIntermediateBufferR0); - if (m_RayTracingIntermediateBufferR1 != null) - RTHandles.Release(m_RayTracingIntermediateBufferR1); - if (m_RayTracingIntermediateBufferRG0 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRG0); - if (m_RayTracingIntermediateBufferRG1 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRG1); - if (m_RayTracingIntermediateBufferRGBA0 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRGBA0); - if (m_RayTracingIntermediateBufferRGBA1 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRGBA1); - if (m_RayTracingIntermediateBufferRGBA2 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRGBA2); - if (m_RayTracingIntermediateBufferRGBA3 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRGBA3); - if (m_RayTracingIntermediateBufferRGBA4 != null) - RTHandles.Release(m_RayTracingIntermediateBufferRGBA4); - if (m_RayTracingLightCluster != null) m_RayTracingLightCluster.ReleaseResources(); if (m_RayCountManager != null) @@ -168,6 +144,33 @@ internal void ReleaseRayTracingManager() m_DiffuseDenoiser.Release(); } + void RaytracingManagerCleanupNonRenderGraphResources() + { + RTHandles.Release(m_RayTracingDistanceBuffer); + m_RayTracingDistanceBuffer = null; + RTHandles.Release(m_RayTracingDirectionBuffer); + m_RayTracingDirectionBuffer = null; + + RTHandles.Release(m_RayTracingIntermediateBufferR0); + m_RayTracingIntermediateBufferR0 = null; + RTHandles.Release(m_RayTracingIntermediateBufferR1); + m_RayTracingIntermediateBufferR1 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRG0); + m_RayTracingIntermediateBufferRG0 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRG1); + m_RayTracingIntermediateBufferRG1 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRGBA0); + m_RayTracingIntermediateBufferRGBA0 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRGBA1); + m_RayTracingIntermediateBufferRGBA1 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRGBA2); + m_RayTracingIntermediateBufferRGBA2 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRGBA3); + m_RayTracingIntermediateBufferRGBA3 = null; + RTHandles.Release(m_RayTracingIntermediateBufferRGBA4); + m_RayTracingIntermediateBufferRGBA4 = null; + } + AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, bool rayTracedShadow, bool aoEnabled, int aoLayerValue, @@ -218,8 +221,8 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, // Grab the material for the current sub-mesh Material currentMaterial = materialArray[meshIdx]; - // The material is transparent if either it has the requested keyword or is in the transparent queue range - if (currentMaterial != null) + // Make sure that the material is both non-null and non-decal + if (currentMaterial != null && !DecalSystem.IsDecalMaterial(currentMaterial)) { // Mesh is valid given that all requirements are ok validMesh = true; @@ -230,7 +233,7 @@ AccelerationStructureStatus AddInstanceToRAS(Renderer currentRenderer, || (HDRenderQueue.k_RenderQueue_Transparent.lowerBound <= currentMaterial.renderQueue && HDRenderQueue.k_RenderQueue_Transparent.upperBound >= currentMaterial.renderQueue); - // aggregate the transparency info + // Aggregate the transparency info materialIsOnlyTransparent &= subMeshTransparentArray[meshIdx]; hasTransparentSubMaterial |= subMeshTransparentArray[meshIdx]; @@ -619,7 +622,7 @@ internal void BuildRayTracingLightData(CommandBuffer cmd, HDCamera hdCamera, Deb m_ValidRayTracingCluster = true; UpdateShaderVariablesRaytracingLightLoopCB(hdCamera, cmd); - + m_RayTracingLightCluster.BuildLightClusterBuffer(cmd, hdCamera, m_RayTracingLights); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingRecursiveRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingRecursiveRenderer.cs index 4b6a79b667e..ddef4b1f079 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingRecursiveRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingRecursiveRenderer.cs @@ -23,7 +23,6 @@ void InitRecursiveRenderer() depthState = new DepthState(false, CompareFunction.LessEqual), mask = RenderStateMask.Depth }; - m_FlagMaskTextureRT = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R8_SNorm, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "FlagMaskTexture"); } internal TextureHandle CreateFlagMaskTexture(RenderGraph renderGraph) @@ -38,11 +37,6 @@ internal TextureHandle CreateFlagMaskTexture(RenderGraph renderGraph) }); } - void ReleaseRecursiveRenderer() - { - RTHandles.Release(m_FlagMaskTextureRT); - } - struct RecursiveRendererParameters { // Camera parameters @@ -211,6 +205,8 @@ TextureHandle RaytracingRecursiveRender(RenderGraph renderGraph, HDCamera hdCame ExecuteRecursiveRendering(ctx.cmd, data.parameters, rrResources); }); + PushFullScreenDebugTexture(m_RenderGraph, passData.debugBuffer, FullScreenDebugMode.RecursiveRayTracing); + return passData.outputBuffer; } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs index eb38922da4b..3426f42bfaa 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs @@ -28,6 +28,12 @@ public sealed class RayTracingSettings : VolumeComponent [Tooltip("Enables the override of the camera culling. This increases the validity area of animated skinned mesh that are outside of the frustum.")] public BoolParameter extendCameraCulling = new BoolParameter(false); + /// + /// Controls the maximal ray length for ray traced shadows. + /// + [Tooltip("Controls the maximal ray length for ray traced directional shadows.")] + public MinFloatParameter directionalShadowRayLength = new MinFloatParameter(1000.0f, 0.01f); + /// /// Default constructor for the ray tracing settings volume component. /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace index 794d68efb98..bd265bf7a45 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace @@ -361,7 +361,7 @@ void RayGenAreaShadowSingle() RW_TEXTURE2D_X(float, _RaytracedShadowIntegration); RW_TEXTURE2D_X(float, _RaytracingDistanceBufferRW); RW_TEXTURE2D_X(float, _VelocityBuffer); -float _DirectionalLightAngle; +float _DirectionalMaxRayLength; [shader("raygeneration")] void RayGenDirectionalShadowSingle() @@ -411,7 +411,7 @@ void RayGenDirectionalShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; // Create and init the RayIntersection structure for this RayIntersection rayIntersection; @@ -478,7 +478,7 @@ void RayGenDirectionalColorShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; // Create and init the RayIntersection structure for this RayIntersection rayIntersection; @@ -495,7 +495,7 @@ void RayGenDirectionalColorShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; rayIntersection.color = float3(1.0, 1.0, 1.0); rayIntersection.t = MISS_RAY_TRACING_SHADOW_DISTANCE; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs index 418e408e2f6..30283dfa3cb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs @@ -143,6 +143,7 @@ internal struct RenderTargets public TextureHandle nonMSAAColorBufferRG; public TextureHandle depthBufferRG; public TextureHandle normalBufferRG; + public TextureHandle motionVectorBufferRG; } enum Version @@ -234,6 +235,7 @@ RenderTargets ReadRenderTargets(in RenderGraphBuilder builder, in RenderTargets output.nonMSAAColorBufferRG = builder.ReadTexture(builder.WriteTexture(targets.nonMSAAColorBufferRG)); output.depthBufferRG = builder.ReadTexture(builder.WriteTexture(targets.depthBufferRG)); output.normalBufferRG = builder.ReadTexture(builder.WriteTexture(targets.normalBufferRG)); + output.motionVectorBufferRG = builder.ReadTexture(targets.motionVectorBufferRG); return output; } @@ -262,6 +264,9 @@ internal void ExecuteInternal(RenderGraph renderGraph, HDCamera hdCamera, Cullin if (customPass.injectionPoint == CustomPassInjectionPoint.AfterPostProcess) ctx.cmd.SetGlobalTexture(HDShaderIDs._AfterPostProcessColorBuffer, customPass.currentRenderTarget.colorBufferRG); + if (customPass.injectionPoint == CustomPassInjectionPoint.BeforePostProcess || customPass.injectionPoint == CustomPassInjectionPoint.AfterPostProcess) + ctx.cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, customPass.currentRenderTarget.motionVectorBufferRG); + if (!customPass.isSetup) { customPass.Setup(ctx.renderContext, ctx.cmd); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs index 204d0f1b12a..c41bc87b960 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs @@ -110,6 +110,8 @@ public sealed class ShaderResources public Shader copyDepthBufferPS; [Reload("Runtime/ShaderLibrary/Blit.shader")] public Shader blitPS; + [Reload("Runtime/ShaderLibrary/BlitColorAndDepth.shader")] + public Shader blitColorAndDepthPS; [Reload("Runtime/ShaderLibrary/DownsampleDepth.shader")] public Shader downsampleDepthPS; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index d783e6006b4..499584b578e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -122,31 +122,11 @@ internal static List GetRenderPipelineMaterialList() return types; } - // Helper to help to display debug info on screen - static float s_OverlayLineHeight = -1.0f; - internal static void ResetOverlay() => s_OverlayLineHeight = -1.0f; - - internal static float GetRuntimeDebugPanelWidth(HDCamera hdCamera) + internal static int GetRuntimeDebugPanelWidth(HDCamera hdCamera) { // 600 is the panel size from 'DebugUI Panel' prefab + 10 pixels of padding - float width = DebugManager.instance.displayRuntimeUI ? 610.0f : 0.0f; - return Mathf.Min(hdCamera.actualWidth, width); - } - - internal static void NextOverlayCoord(ref float x, ref float y, float overlayWidth, float overlayHeight, HDCamera hdCamera) - { - x += overlayWidth; - s_OverlayLineHeight = Mathf.Max(overlayHeight, s_OverlayLineHeight); - // Go to next line if it goes outside the screen. - if ( (x + overlayWidth) > hdCamera.actualWidth) - { - x = 0.0f; - y -= s_OverlayLineHeight; - s_OverlayLineHeight = -1.0f; - } - - if (x == 0) - x += GetRuntimeDebugPanelWidth(hdCamera); + int width = DebugManager.instance.displayRuntimeUI ? 610 : 0; + return Math.Min(hdCamera.actualWidth, width); } /// Get the aspect ratio of a projection matrix. @@ -327,6 +307,32 @@ public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scale s_PropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, mipLevel); BlitTexture(cmd, source, scaleBias, GetBlitMaterial(TextureXR.dimension), bilinear ? 1 : 0); } + + /// + /// Blit a 2D texture and depth buffer. + /// + /// Command Buffer used for rendering. + /// Source Texture for color. + /// Source RenderTexture for depth. + /// Scale and bias for sampling the input texture. + /// Mip level to blit. + /// Enable bilinear filtering. + internal static void BlitColorAndDepth(CommandBuffer cmd, Texture sourceColor, RenderTexture sourceDepth, Vector4 scaleBias, float mipLevel, bool blitDepth) + { + HDRenderPipeline hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline; + if (hdPipeline != null) + { + Material mat = hdPipeline.GetBlitColorAndDepthMaterial(); + + s_PropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, mipLevel); + s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBias, scaleBias); + s_PropertyBlock.SetTexture(HDShaderIDs._BlitTexture, sourceColor); + if (blitDepth) + s_PropertyBlock.SetTexture(HDShaderIDs._InputDepth, sourceDepth, RenderTextureSubElement.Depth); + cmd.DrawProcedural(Matrix4x4.identity, mat, blitDepth ? 1 : 0, MeshTopology.Triangles, 3, 1, s_PropertyBlock); + } + } + /// /// Blit a RTHandle texture /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset index 7ea01347b1e..401d03bcdb4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset @@ -15,120 +15,190 @@ MonoBehaviour: m_Version: 4 shaders: defaultPS: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3} - debugDisplayLatlongPS: {fileID: 4800000, guid: c1d1d149a043a5349ba367da6c2051ba, type: 3} - debugViewMaterialGBufferPS: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d, type: 3} + debugDisplayLatlongPS: {fileID: 4800000, guid: c1d1d149a043a5349ba367da6c2051ba, + type: 3} + debugViewMaterialGBufferPS: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d, + type: 3} debugViewTilesPS: {fileID: 4800000, guid: c7c2bd17b06ceb4468e14081aaf1b96f, type: 3} debugFullScreenPS: {fileID: 4800000, guid: e874aca2df8300a488258738c31f85cf, type: 3} - debugColorPickerPS: {fileID: 4800000, guid: 8137b807709e178498f22ed710864bb0, type: 3} + debugColorPickerPS: {fileID: 4800000, guid: 8137b807709e178498f22ed710864bb0, + type: 3} debugExposurePS: {fileID: 4800000, guid: 0ef322534f047a34c96d29419d56d17a, type: 3} - debugLightVolumePS: {fileID: 4800000, guid: 8e706c0e71fcec34a8f5c9713e5e2943, type: 3} - debugLightVolumeCS: {fileID: 7200000, guid: f5d5d21faef5cf445ac2c5d8ff9c4184, type: 3} + debugLightVolumePS: {fileID: 4800000, guid: 8e706c0e71fcec34a8f5c9713e5e2943, + type: 3} + debugLightVolumeCS: {fileID: 7200000, guid: f5d5d21faef5cf445ac2c5d8ff9c4184, + type: 3} debugBlitQuad: {fileID: 4800000, guid: cf5ca5b6ef18b3f429ed707ee9ceac9f, type: 3} - debugViewVirtualTexturingBlit: {fileID: 4800000, guid: 55d195396b03b804eb78c92d468e3c8e, type: 3} + debugViewVirtualTexturingBlit: {fileID: 4800000, guid: 55d195396b03b804eb78c92d468e3c8e, + type: 3} + materialError: {fileID: 4800000, guid: 79a966a5200a456188dec0d48d805614, type: 3} deferredPS: {fileID: 4800000, guid: 00dd221e34a6ab349a1196b0f2fab693, type: 3} colorPyramidPS: {fileID: 4800000, guid: 2fcfb8d92f45e4549b3f0bad5d0654bf, type: 3} depthPyramidCS: {fileID: 7200000, guid: 64a553bb564274041906f78ffba955e4, type: 3} copyChannelCS: {fileID: 7200000, guid: a4d45eda75e8e474dbe24a31f741f3b4, type: 3} - screenSpaceReflectionsCS: {fileID: 7200000, guid: d1de9ac7d9016204da289affe9677942, type: 3} + screenSpaceReflectionsCS: {fileID: 7200000, guid: d1de9ac7d9016204da289affe9677942, + type: 3} applyDistortionPS: {fileID: 4800000, guid: 02ae56f4306413c4a96dcf005cde1971, type: 3} - clearDispatchIndirectCS: {fileID: 7200000, guid: fc1f553acb80a6446a32d33e403d0656, type: 3} + clearDispatchIndirectCS: {fileID: 7200000, guid: fc1f553acb80a6446a32d33e403d0656, + type: 3} clearLightListsCS: {fileID: 7200000, guid: 743eb3491795b9545955695d591195a1, type: 3} - buildDispatchIndirectCS: {fileID: 7200000, guid: 4eb1b418be7044c40bb5200496c50f14, type: 3} + buildDispatchIndirectCS: {fileID: 7200000, guid: 4eb1b418be7044c40bb5200496c50f14, + type: 3} buildScreenAABBCS: {fileID: 7200000, guid: 728dce960f8a9c44bbc3abb3b851d8f6, type: 3} - buildPerTileLightListCS: {fileID: 7200000, guid: 65af3444cbf4b3747a4dead7ee00cfee, type: 3} - buildPerBigTileLightListCS: {fileID: 7200000, guid: 5ee1f9d6e09abe045b2f5e0b784b9072, type: 3} - buildPerVoxelLightListCS: {fileID: 7200000, guid: 0bb1b7e0ddcd5c44baf3ddc7456eb196, type: 3} - lightListClusterClearAtomicIndexCS: {fileID: 7200000, guid: 1e3472a94b14a334a93230bbc700d7b2, type: 3} - buildMaterialFlagsCS: {fileID: 7200000, guid: fb3eda953cd6e634e877fb777be2cd08, type: 3} + buildPerTileLightListCS: {fileID: 7200000, guid: 65af3444cbf4b3747a4dead7ee00cfee, + type: 3} + buildPerBigTileLightListCS: {fileID: 7200000, guid: 5ee1f9d6e09abe045b2f5e0b784b9072, + type: 3} + buildPerVoxelLightListCS: {fileID: 7200000, guid: 0bb1b7e0ddcd5c44baf3ddc7456eb196, + type: 3} + lightListClusterClearAtomicIndexCS: {fileID: 7200000, guid: 1e3472a94b14a334a93230bbc700d7b2, + type: 3} + buildMaterialFlagsCS: {fileID: 7200000, guid: fb3eda953cd6e634e877fb777be2cd08, + type: 3} deferredCS: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259, type: 3} contactShadowCS: {fileID: 7200000, guid: 3e6900e06dc185a4380af4dacb4db0a4, type: 3} - volumeVoxelizationCS: {fileID: 7200000, guid: c20b371db720da244b73830ec74a343a, type: 3} - volumetricLightingCS: {fileID: 7200000, guid: b4901a10df2d1e24282725e9fbc77c97, type: 3} - volumetricLightingFilteringCS: {fileID: 7200000, guid: ef9a910d0ec6ebb41ae3f5c7a69daf46, type: 3} + volumeVoxelizationCS: {fileID: 7200000, guid: c20b371db720da244b73830ec74a343a, + type: 3} + volumetricLightingCS: {fileID: 7200000, guid: b4901a10df2d1e24282725e9fbc77c97, + type: 3} + volumetricLightingFilteringCS: {fileID: 7200000, guid: ef9a910d0ec6ebb41ae3f5c7a69daf46, + type: 3} deferredTilePS: {fileID: 4800000, guid: dedaf4ea0d134ca4aad1d95a558c46e5, type: 3} - screenSpaceShadowPS: {fileID: 4800000, guid: bfa43a48695613b4ea19c58858ae1a61, type: 3} - probeVolumeAtlasBlitCS: {fileID: 7200000, guid: 07f429bf534edb44eb5a0e4b2c65b108, type: 3} - probeVolumeAtlasOctahedralDepthBlitCS: {fileID: 7200000, guid: f60c895d3a3061848844b36ccf9e44a9, type: 3} - probeVolumeAtlasOctahedralDepthConvolveCS: {fileID: 7200000, guid: 7ef71ce05401a4c4081039b475d3b9ee, type: 3} - debugDisplayProbeVolumePS: {fileID: 4800000, guid: e7c19cfee7a88394fbb53652b9644cc0, type: 3} - subsurfaceScatteringCS: {fileID: 7200000, guid: b06a7993621def248addd55d0fe931b1, type: 3} + screenSpaceShadowPS: {fileID: 4800000, guid: bfa43a48695613b4ea19c58858ae1a61, + type: 3} + probeVolumeAtlasBlitCS: {fileID: 7200000, guid: 07f429bf534edb44eb5a0e4b2c65b108, + type: 3} + probeVolumeAtlasOctahedralDepthBlitCS: {fileID: 7200000, guid: f60c895d3a3061848844b36ccf9e44a9, + type: 3} + probeVolumeAtlasOctahedralDepthConvolveCS: {fileID: 7200000, guid: 7ef71ce05401a4c4081039b475d3b9ee, + type: 3} + debugDisplayProbeVolumePS: {fileID: 4800000, guid: e7c19cfee7a88394fbb53652b9644cc0, + type: 3} + subsurfaceScatteringCS: {fileID: 7200000, guid: b06a7993621def248addd55d0fe931b1, + type: 3} combineLightingPS: {fileID: 4800000, guid: 2e37131331fbdca449b1a2bc47a639ca, type: 3} - cameraMotionVectorsPS: {fileID: 4800000, guid: 035941b63024d1943af48811c1db20d9, type: 3} - clearStencilBufferPS: {fileID: 4800000, guid: 8ea49ef16606acd489439e676ab84040, type: 3} - copyStencilBufferPS: {fileID: 4800000, guid: 3d1574f1cdfa0ce4995f9bc79ed7f8ec, type: 3} + cameraMotionVectorsPS: {fileID: 4800000, guid: 035941b63024d1943af48811c1db20d9, + type: 3} + clearStencilBufferPS: {fileID: 4800000, guid: 8ea49ef16606acd489439e676ab84040, + type: 3} + copyStencilBufferPS: {fileID: 4800000, guid: 3d1574f1cdfa0ce4995f9bc79ed7f8ec, + type: 3} copyDepthBufferPS: {fileID: 4800000, guid: 42dfcc8fe803ece4096c58630689982f, type: 3} blitPS: {fileID: 4800000, guid: 370f7a9cc4e362d488af024d371091e8, type: 3} + blitColorAndDepthPS: {fileID: 4800000, guid: c6e57f5bdbd2a284a86a3097c03884c8, + type: 3} downsampleDepthPS: {fileID: 4800000, guid: 67d6171b0acc6554aad48c845ec7e67f, type: 3} - upsampleTransparentPS: {fileID: 4800000, guid: 2ad7ce40f0dbaf64dadef1f58d8524d3, type: 3} + upsampleTransparentPS: {fileID: 4800000, guid: 2ad7ce40f0dbaf64dadef1f58d8524d3, + type: 3} resolveStencilCS: {fileID: 7200000, guid: 65b89cac5f286b043a31bf8041776ee7, type: 3} blitCubemapPS: {fileID: 4800000, guid: d05913e251bed7a4992c921c62e1b647, type: 3} - buildProbabilityTablesCS: {fileID: 7200000, guid: b9f26cf340afe9145a699753531b2a4c, type: 3} - computeGgxIblSampleDataCS: {fileID: 7200000, guid: 764a24bb47ef5ba4781d9ae82ca07445, type: 3} + buildProbabilityTablesCS: {fileID: 7200000, guid: b9f26cf340afe9145a699753531b2a4c, + type: 3} + computeGgxIblSampleDataCS: {fileID: 7200000, guid: 764a24bb47ef5ba4781d9ae82ca07445, + type: 3} GGXConvolvePS: {fileID: 4800000, guid: 123ed592ad5c2494b8aed301fd609e7b, type: 3} charlieConvolvePS: {fileID: 4800000, guid: 5685fd17e71045e4ca9fefca38a7c177, type: 3} - opaqueAtmosphericScatteringPS: {fileID: 4800000, guid: 32f724728cf19904291226f239ec16f0, type: 3} + opaqueAtmosphericScatteringPS: {fileID: 4800000, guid: 32f724728cf19904291226f239ec16f0, + type: 3} hdriSkyPS: {fileID: 4800000, guid: 9bd32a6ece529fd4f9408b8d7e00c10d, type: 3} - integrateHdriSkyPS: {fileID: 4800000, guid: 48db2705cf2856d4e893eb30a6892d1b, type: 3} + integrateHdriSkyPS: {fileID: 4800000, guid: 48db2705cf2856d4e893eb30a6892d1b, + type: 3} skyboxCubemapPS: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0} gradientSkyPS: {fileID: 4800000, guid: 2b5d4f1b26f03dc4a873b093e0c4adb1, type: 3} - ambientProbeConvolutionCS: {fileID: 7200000, guid: 6d048f7b1bd45e840b4e79ec92639fa8, type: 3} - groundIrradiancePrecomputationCS: {fileID: 7200000, guid: eb6ae6f326207ee4d987a3e5adddf63a, type: 3} - inScatteredRadiancePrecomputationCS: {fileID: 7200000, guid: 70c69d514688f8545855680760d77418, type: 3} - physicallyBasedSkyPS: {fileID: 4800000, guid: a06934a4863e778498be65d8f865b7a4, type: 3} - planarReflectionFilteringCS: {fileID: 7200000, guid: 9f3f8a01b8caaaa4595591dc96d43dd2, type: 3} - preIntegratedFGD_GGXDisneyDiffusePS: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3} - preIntegratedFGD_CharlieFabricLambertPS: {fileID: 4800000, guid: 3b3bf235775cf8b4baae7f3306787ab0, type: 3} - preIntegratedFGD_WardPS: {fileID: 4800000, guid: d279c46a545b0af4f9f0c4fa82cd489e, type: 3} - preIntegratedFGD_CookTorrancePS: {fileID: 4800000, guid: a6402c19b020b4a4fb7073aaa2e26aba, type: 3} + ambientProbeConvolutionCS: {fileID: 7200000, guid: 6d048f7b1bd45e840b4e79ec92639fa8, + type: 3} + groundIrradiancePrecomputationCS: {fileID: 7200000, guid: eb6ae6f326207ee4d987a3e5adddf63a, + type: 3} + inScatteredRadiancePrecomputationCS: {fileID: 7200000, guid: 70c69d514688f8545855680760d77418, + type: 3} + physicallyBasedSkyPS: {fileID: 4800000, guid: a06934a4863e778498be65d8f865b7a4, + type: 3} + planarReflectionFilteringCS: {fileID: 7200000, guid: 9f3f8a01b8caaaa4595591dc96d43dd2, + type: 3} + preIntegratedFGD_GGXDisneyDiffusePS: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, + type: 3} + preIntegratedFGD_CharlieFabricLambertPS: {fileID: 4800000, guid: 3b3bf235775cf8b4baae7f3306787ab0, + type: 3} + preIntegratedFGD_WardPS: {fileID: 4800000, guid: d279c46a545b0af4f9f0c4fa82cd489e, + type: 3} + preIntegratedFGD_CookTorrancePS: {fileID: 4800000, guid: a6402c19b020b4a4fb7073aaa2e26aba, + type: 3} encodeBC6HCS: {fileID: 7200000, guid: aa922d239de60304f964e24488559eeb, type: 3} cubeToPanoPS: {fileID: 4800000, guid: 595434cc3b6405246b6cd3086d0b6f7d, type: 3} - blitCubeTextureFacePS: {fileID: 4800000, guid: d850d0a2481878d4bbf17e5126b04163, type: 3} - filterAreaLightCookiesPS: {fileID: 4800000, guid: c243aac96dda5fa40bed693ed5ba02c4, type: 3} - clearUIntTextureCS: {fileID: 7200000, guid: d067ad4b88af51c498875426894aef76, type: 3} + blitCubeTextureFacePS: {fileID: 4800000, guid: d850d0a2481878d4bbf17e5126b04163, + type: 3} + filterAreaLightCookiesPS: {fileID: 4800000, guid: c243aac96dda5fa40bed693ed5ba02c4, + type: 3} + clearUIntTextureCS: {fileID: 7200000, guid: d067ad4b88af51c498875426894aef76, + type: 3} customPassUtils: {fileID: 4800000, guid: 7e3722d0388000848acb25fd3cc8c088, type: 3} - customPassRenderersUtils: {fileID: 4800000, guid: cef5ba33ee5063d4c8b495d2292e394d, type: 3} + customPassRenderersUtils: {fileID: 4800000, guid: cef5ba33ee5063d4c8b495d2292e394d, + type: 3} xrMirrorViewPS: {fileID: 4800000, guid: e6255f98cf405eb45ab6f9006cf11e1f, type: 3} xrOcclusionMeshPS: {fileID: 4800000, guid: 46a45b32bb110604fb36216b63bcdb81, type: 3} shadowClearPS: {fileID: 4800000, guid: e3cab24f27741f44d8af1e94d006267c, type: 3} evsmBlurCS: {fileID: 7200000, guid: fb36979473602464fa32deacb9630c08, type: 3} - debugHDShadowMapPS: {fileID: 4800000, guid: 93d40cc9a6e13994f86f576a624efa18, type: 3} + debugHDShadowMapPS: {fileID: 4800000, guid: 93d40cc9a6e13994f86f576a624efa18, + type: 3} momentShadowsCS: {fileID: 7200000, guid: 4dea53e2ff15ed0448817c2aa4246e53, type: 3} - decalNormalBufferPS: {fileID: 4800000, guid: fd532bf1795188c4daaa66ea798b8b0a, type: 3} - decalClearPropertyMaskBufferCS: {fileID: 7200000, guid: 1076a08965d4a91479b72599724f7fd6, type: 3} + decalNormalBufferPS: {fileID: 4800000, guid: fd532bf1795188c4daaa66ea798b8b0a, + type: 3} GTAOCS: {fileID: 7200000, guid: 6710b06492bd58c4bb8aec0fdc1fced3, type: 3} - GTAOSpatialDenoiseCS: {fileID: 7200000, guid: 2cb33c21587d12b4388d7866ab6c65f6, type: 3} - GTAOTemporalDenoiseCS: {fileID: 7200000, guid: 31e0ca4c210f97c468037d11a5b832bb, type: 3} + GTAOSpatialDenoiseCS: {fileID: 7200000, guid: 2cb33c21587d12b4388d7866ab6c65f6, + type: 3} + GTAOTemporalDenoiseCS: {fileID: 7200000, guid: 31e0ca4c210f97c468037d11a5b832bb, + type: 3} GTAOCopyHistoryCS: {fileID: 7200000, guid: 7f43be57ffd12ff469d4fc175c00c4b4, type: 3} - GTAOBlurAndUpsample: {fileID: 7200000, guid: 9eb1abde882538a4ea46fa23e49ab9fa, type: 3} - screenSpaceGlobalIlluminationCS: {fileID: 7200000, guid: 96170a954eb538b40a5ff369552c3629, type: 3} + GTAOBlurAndUpsample: {fileID: 7200000, guid: 9eb1abde882538a4ea46fa23e49ab9fa, + type: 3} + screenSpaceGlobalIlluminationCS: {fileID: 7200000, guid: 96170a954eb538b40a5ff369552c3629, + type: 3} depthValuesPS: {fileID: 4800000, guid: 6e6a4a3dbb788234594aa74f2d6aeb6f, type: 3} colorResolvePS: {fileID: 4800000, guid: dd7047092f3c82b40b3a07868f9c4de2, type: 3} - resolveMotionVecPS: {fileID: 4800000, guid: ea18ca9826385e943979c46cf98968cc, type: 3} + resolveMotionVecPS: {fileID: 4800000, guid: ea18ca9826385e943979c46cf98968cc, + type: 3} copyAlphaCS: {fileID: 7200000, guid: c2c7eb6611725264187721ef9df0354b, type: 3} nanKillerCS: {fileID: 7200000, guid: 83982f199acf927499576a99abc9bea9, type: 3} exposureCS: {fileID: 7200000, guid: 976d7bce54fae534fb9ec67e9c18570c, type: 3} - histogramExposureCS: {fileID: 7200000, guid: 222da48299136f34b8e3fb75ae9f8ac7, type: 3} + histogramExposureCS: {fileID: 7200000, guid: 222da48299136f34b8e3fb75ae9f8ac7, + type: 3} applyExposureCS: {fileID: 7200000, guid: 1a6fea1dc099b984d8f2b27d504dc096, type: 3} - debugImageHistogramCS: {fileID: 7200000, guid: 52cc17ef5a5ffc443a5c142f9b745a85, type: 3} + debugImageHistogramCS: {fileID: 7200000, guid: 52cc17ef5a5ffc443a5c142f9b745a85, + type: 3} uberPostCS: {fileID: 7200000, guid: f1bf52f7c71bffd4f91e6cd90d12a4f7, type: 3} lutBuilder3DCS: {fileID: 7200000, guid: 37f2b1b0ecd6f1c439e4c1b4f2fdb524, type: 3} - depthOfFieldKernelCS: {fileID: 7200000, guid: 7869415cc3e4eaa4d82ac21a752a2780, type: 3} + depthOfFieldKernelCS: {fileID: 7200000, guid: 7869415cc3e4eaa4d82ac21a752a2780, + type: 3} depthOfFieldCoCCS: {fileID: 7200000, guid: 048b235b54fbfaa4d80ec85ea847d4f8, type: 3} - depthOfFieldCoCReprojectCS: {fileID: 7200000, guid: 4980decaa3878d6448569489f5fc7931, type: 3} - depthOfFieldDilateCS: {fileID: 7200000, guid: 1c93af4338c0c1b42b92464992eebc10, type: 3} + depthOfFieldCoCReprojectCS: {fileID: 7200000, guid: 4980decaa3878d6448569489f5fc7931, + type: 3} + depthOfFieldDilateCS: {fileID: 7200000, guid: 1c93af4338c0c1b42b92464992eebc10, + type: 3} depthOfFieldMipCS: {fileID: 7200000, guid: d3ef53de069ded64e8377cba6eb951fa, type: 3} - depthOfFieldMipSafeCS: {fileID: 7200000, guid: 2d24ee7b2c804d947a5c371c12ed46bd, type: 3} - depthOfFieldPrefilterCS: {fileID: 7200000, guid: f2b89d19910854346b792fe7177ce634, type: 3} - depthOfFieldTileMaxCS: {fileID: 7200000, guid: 84f84585ea8a7a849bea4a581adb93a7, type: 3} - depthOfFieldGatherCS: {fileID: 7200000, guid: 486be52dddc4e054fb10a7b9b78788c2, type: 3} - depthOfFieldCombineCS: {fileID: 7200000, guid: c8049ca85c4c7d047ba28f34d800c663, type: 3} - depthOfFieldPreCombineFarCS: {fileID: 7200000, guid: 3b4a2acd03d1ce2438d93c325d588735, type: 3} - depthOfFieldClearIndirectArgsCS: {fileID: 7200000, guid: 69905045e1d0a65458b205d6ab55502b, type: 3} - paniniProjectionCS: {fileID: 7200000, guid: 0ddbf72c8fbb6e44b983f470c8384ef6, type: 3} - motionBlurMotionVecPrepCS: {fileID: 7200000, guid: ed9438fa777911d48933402087203b15, type: 3} - motionBlurGenTileCS: {fileID: 7200000, guid: 336e1fdbb3a1b8647b06208415f87804, type: 3} - motionBlurMergeTileCS: {fileID: 7200000, guid: cd14ddf849edeed43b0e3ccf66023038, type: 3} - motionBlurNeighborhoodTileCS: {fileID: 7200000, guid: 5ea9865df3e53b448856785b88f8e7b9, type: 3} + depthOfFieldMipSafeCS: {fileID: 7200000, guid: 2d24ee7b2c804d947a5c371c12ed46bd, + type: 3} + depthOfFieldPrefilterCS: {fileID: 7200000, guid: f2b89d19910854346b792fe7177ce634, + type: 3} + depthOfFieldTileMaxCS: {fileID: 7200000, guid: 84f84585ea8a7a849bea4a581adb93a7, + type: 3} + depthOfFieldGatherCS: {fileID: 7200000, guid: 486be52dddc4e054fb10a7b9b78788c2, + type: 3} + depthOfFieldCombineCS: {fileID: 7200000, guid: c8049ca85c4c7d047ba28f34d800c663, + type: 3} + depthOfFieldPreCombineFarCS: {fileID: 7200000, guid: 3b4a2acd03d1ce2438d93c325d588735, + type: 3} + depthOfFieldClearIndirectArgsCS: {fileID: 7200000, guid: 69905045e1d0a65458b205d6ab55502b, + type: 3} + paniniProjectionCS: {fileID: 7200000, guid: 0ddbf72c8fbb6e44b983f470c8384ef6, + type: 3} + motionBlurMotionVecPrepCS: {fileID: 7200000, guid: ed9438fa777911d48933402087203b15, + type: 3} + motionBlurGenTileCS: {fileID: 7200000, guid: 336e1fdbb3a1b8647b06208415f87804, + type: 3} + motionBlurMergeTileCS: {fileID: 7200000, guid: cd14ddf849edeed43b0e3ccf66023038, + type: 3} + motionBlurNeighborhoodTileCS: {fileID: 7200000, guid: 5ea9865df3e53b448856785b88f8e7b9, + type: 3} motionBlurCS: {fileID: 7200000, guid: 2af5c49c7865edb4b823826970ec176a, type: 3} bloomPrefilterCS: {fileID: 7200000, guid: 243b24008041aaa4a91800690f63c684, type: 3} bloomBlurCS: {fileID: 7200000, guid: 133a68380d324de4ea8d3ff8657b02d8, type: 3} @@ -137,18 +207,23 @@ MonoBehaviour: finalPassPS: {fileID: 4800000, guid: 5ac9ef0c50282754b93c7692488e7ee7, type: 3} clearBlackPS: {fileID: 4800000, guid: 3330c1503ea8c6d4d9408df3f64227eb, type: 3} SMAAPS: {fileID: 4800000, guid: 9655f4aa89a469c49aceaceabf9bc77b, type: 3} - temporalAntialiasingPS: {fileID: 4800000, guid: 3dd9fd928fdb83743b1f27d15df22179, type: 3} - dofCircleOfConfusion: {fileID: 7200000, guid: 75332b7b315c80d4babe506820aa0bfd, type: 3} + temporalAntialiasingPS: {fileID: 4800000, guid: 3dd9fd928fdb83743b1f27d15df22179, + type: 3} + dofCircleOfConfusion: {fileID: 7200000, guid: 75332b7b315c80d4babe506820aa0bfd, + type: 3} dofGatherCS: {fileID: 7200000, guid: 1e6b16a7970a1494db74b1d3d007d1cc, type: 3} DoFCoCPyramidCS: {fileID: 7200000, guid: df41a69211c03fe479b63a8bed3bfbb4, type: 3} - contrastAdaptiveSharpenCS: {fileID: 7200000, guid: 560896aec2f412c48995be35551a4ac6, type: 3} - VTFeedbackDownsample: {fileID: 7200000, guid: 32d963548086c2c439aeb23a93e9a00a, type: 3} + contrastAdaptiveSharpenCS: {fileID: 7200000, guid: 560896aec2f412c48995be35551a4ac6, + type: 3} + VTFeedbackDownsample: {fileID: 7200000, guid: 32d963548086c2c439aeb23a93e9a00a, + type: 3} accumulationCS: {fileID: 7200000, guid: ed80add7a217efa468d137d6f7c668f3, type: 3} alphaInjectionPS: {fileID: 4800000, guid: 4edd96259a5e8b44c90479928f0cd11e, type: 3} chromaKeyingPS: {fileID: 4800000, guid: 49feb6b111e82ec4eb6d3d08e4b6903e, type: 3} customClearPS: {fileID: 4800000, guid: 9cef3686fa32c8840947ed99b561195c, type: 3} ssGIDenoiserCS: {fileID: 7200000, guid: a435d803bc32d0845ba1a713b7a1c8b1, type: 3} - bilateralUpsampleCS: {fileID: 7200000, guid: 68e831c555284d741b985e05369f0e63, type: 3} + bilateralUpsampleCS: {fileID: 7200000, guid: 68e831c555284d741b985e05369f0e63, + type: 3} textures: debugFontTex: {fileID: 2800000, guid: a3ad2df0e49aaa341a3b3a80f93b3f66, type: 3} colorGradient: {fileID: 2800000, guid: 4ea52e665573c1644bf05dd9b11fd2a4, type: 3} @@ -219,15 +294,20 @@ MonoBehaviour: - {fileID: 2800000, guid: 7641a2b116fafd64d9c3d6459fdfe801, type: 3} - {fileID: 2800000, guid: c6a5e40e6746fef4fa486e8f620ee8d4, type: 3} - {fileID: 2800000, guid: fd4189357c6dfb94fa2d36afbce72086, type: 3} - owenScrambledRGBATex: {fileID: 2800000, guid: b0fe077c1ee7d80428f3d8dfa28a027d, type: 3} - owenScrambled256Tex: {fileID: 2800000, guid: 2a205358e67aa9e4a94a128ac9362f4e, type: 3} + owenScrambledRGBATex: {fileID: 2800000, guid: b0fe077c1ee7d80428f3d8dfa28a027d, + type: 3} + owenScrambled256Tex: {fileID: 2800000, guid: 2a205358e67aa9e4a94a128ac9362f4e, + type: 3} scramblingTex: {fileID: 2800000, guid: bf25cd6288e2c8d43854a61a8496a830, type: 3} rankingTile1SPP: {fileID: 2800000, guid: f2fe0251f704c4c478a8063775cffedb, type: 3} - scramblingTile1SPP: {fileID: 2800000, guid: 6185473f62ad3e74da4acac5d482917a, type: 3} + scramblingTile1SPP: {fileID: 2800000, guid: 6185473f62ad3e74da4acac5d482917a, + type: 3} rankingTile8SPP: {fileID: 2800000, guid: af4bd638a4b3eb14781e6441adcdfbb9, type: 3} - scramblingTile8SPP: {fileID: 2800000, guid: 152f8b933250a7b448fc2d4d301b9944, type: 3} + scramblingTile8SPP: {fileID: 2800000, guid: 152f8b933250a7b448fc2d4d301b9944, + type: 3} rankingTile256SPP: {fileID: 2800000, guid: 1e604a266c415cd46b36d97cd9220aa8, type: 3} - scramblingTile256SPP: {fileID: 2800000, guid: 882fb55d7b3e7c94598a318df9376e32, type: 3} + scramblingTile256SPP: {fileID: 2800000, guid: 882fb55d7b3e7c94598a318df9376e32, + type: 3} filmGrainTex: - {fileID: 2800000, guid: 284a1ac236869fa4eacf377d73c7dff8, type: 3} - {fileID: 2800000, guid: bd74961b009b93145a998ae93a5fc186, type: 3} @@ -243,6 +323,8 @@ MonoBehaviour: SMAAAreaTex: {fileID: 2800000, guid: 92e0d85ab4eca874098e7fcf6f8f674e, type: 3} defaultHDRISky: {fileID: 8900000, guid: 8253d41e6e8b11a4cbe77a4f8f82934d, type: 3} assets: - defaultDiffusionProfile: {fileID: 11400000, guid: 2b7005ba3a4d8474b8cdc34141ad766e, type: 2} - emissiveCylinderMesh: {fileID: 2534964839176971238, guid: accb6d90f0d50fe4ca0f68159b4323de, type: 3} + defaultDiffusionProfile: {fileID: 11400000, guid: 2b7005ba3a4d8474b8cdc34141ad766e, + type: 2} + emissiveCylinderMesh: {fileID: 2534964839176971238, guid: accb6d90f0d50fe4ca0f68159b4323de, + type: 3} emissiveQuadMesh: {fileID: 4300000, guid: 1d5a8595286f94f4bb54171d49f473c3, type: 3} diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader new file mode 100644 index 00000000000..d63396de25c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader @@ -0,0 +1,97 @@ +Shader "Hidden/HDRP/BlitColorAndDepth" +{ + HLSLINCLUDE + + #pragma target 4.5 + #pragma editor_sync_compilation + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch + #pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY + #pragma multi_compile _ BLIT_SINGLE_SLICE + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" + + TEXTURE2D (_BlitTexture); + TEXTURE2D (_InputDepthTexture); + SamplerState sampler_PointClamp; + SamplerState sampler_LinearClamp; + uniform float4 _BlitScaleBias; + uniform float _BlitMipLevel; + + struct Attributes + { + uint vertexID : SV_VertexID; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 positionCS : SV_POSITION; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_OUTPUT_STEREO + }; + + Varyings Vert(Attributes input) + { + Varyings output; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); + output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID) * _BlitScaleBias.xy + _BlitScaleBias.zw; + return output; + } + + float4 FragColorOnly(Varyings input) : SV_Target + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + return SAMPLE_TEXTURE2D_LOD(_BlitTexture, sampler_LinearClamp, input.texcoord.xy, _BlitMipLevel); + } + + struct PixelData + { + float4 color : SV_Target; + float depth : SV_Depth; + }; + + PixelData FragColorAndDepth(Varyings input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + PixelData pd; + pd.color = SAMPLE_TEXTURE2D_LOD(_BlitTexture, sampler_LinearClamp, input.texcoord.xy, _BlitMipLevel); + pd.depth = SAMPLE_TEXTURE2D_LOD(_InputDepthTexture, sampler_PointClamp, input.texcoord.xy, _BlitMipLevel).x; + return pd; + } + + ENDHLSL + + SubShader + { + Tags{ "RenderPipeline" = "HDRenderPipeline" } + + // 0: Color Only + Pass + { + ZWrite Off ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment FragColorOnly + ENDHLSL + } + + // 1: Color Only and Depth + Pass + { + ZWrite On ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment FragColorAndDepth + ENDHLSL + } + + } + + Fallback Off +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader.meta b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader.meta new file mode 100644 index 00000000000..495357f7108 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/BlitColorAndDepth.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c6e57f5bdbd2a284a86a3097c03884c8 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl index ab9a3831ff1..990e9e25c42 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesFunctions.hlsl @@ -2,6 +2,7 @@ #define UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl" // Helper function for Rendering Layers #define DEFAULT_LIGHT_LAYERS (RENDERING_LIGHT_LAYERS_MASK >> RENDERING_LIGHT_LAYERS_MASK_SHIFT) @@ -206,5 +207,36 @@ uint ScalarizeElementIndex(uint v_elementIdx, bool fastPath) return s_elementIdx; } +//----------------------------------------------------------------------------- +// LoD Fade +//----------------------------------------------------------------------------- + +// Helper for LODDitheringTransition. +uint2 ComputeFadeMaskSeed(float3 V, uint2 positionSS) +{ + uint2 fadeMaskSeed; + + if (IsPerspectiveProjection()) + { + // Start with the world-space direction V. It is independent from the orientation of the camera, + // and only depends on the position of the camera and the position of the fragment. + // Now, project and transform it into [-1, 1]. + float2 pv = PackNormalOctQuadEncode(V); + // Rescale it to account for the resolution of the screen. + pv *= _ScreenSize.xy; + // The camera only sees a small portion of the sphere, limited by hFoV and vFoV. + // Therefore, we must rescale again (before quantization), roughly, by 1/tan(FoV/2). + pv *= UNITY_MATRIX_P._m00_m11; + // Truncate and quantize. + fadeMaskSeed = asuint((int2)pv); + } + else + { + // Can't use the view direction, it is the same across the entire screen. + fadeMaskSeed = positionSS; + } + + return fadeMaskSeed; +} #endif // UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader index 7d0ccb09962..0a05e669a03 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.shader @@ -146,7 +146,7 @@ Shader "Hidden/HDRP/Sky/PbrSky" float w = saturate(1 - r * rcp(light.flareSize)); color *= light.flareTint; - scale *= pow(w, light.flareFalloff); + scale *= SafePositivePow(w, light.flareFalloff); } radiance += color * scale; diff --git a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs index db677ae9feb..bfb11b374ff 100644 --- a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs +++ b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs @@ -58,14 +58,6 @@ public IEnumerator Run(GraphicsTestCase testCase) } } - if (HDRenderPipeline.enableRenderGraphTests) - { - if (!settings.renderGraphCompatible) - { - Assert.Ignore("Test scene is not compatible with Render Graph and will be skipped."); - } - } - if (settings.doBeforeTest != null) { settings.doBeforeTest.Invoke(); @@ -86,7 +78,10 @@ public IEnumerator Run(GraphicsTestCase testCase) // Standard Test ImageAssert.AreEqual(testCase.ReferenceImage, camera, settings?.ImageComparisonSettings); - if (settings.checkMemoryAllocation) + // For some reason, tests on mac os have started failing with render graph enabled by default. + // Some tests have 400+ gcalloc in them. Unfortunately it's not reproductible outside of command line so it's impossible to debug. + // That's why we don't test on macos anymore. + if (settings.checkMemoryAllocation && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal) { // Does it allocate memory when it renders what's on camera? bool allocatesMemory = false; diff --git a/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs b/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs index bd2fa578af2..fd673a19472 100644 --- a/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs +++ b/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs @@ -23,7 +23,6 @@ public class HDRP_TestSettings : GraphicsTestSettings [UnityEngine.Range(1.0f, 10.0f)] public float xrThresholdMultiplier = 1.0f; - public bool renderGraphCompatible = true; public bool checkMemoryAllocation = true;