diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index a40eb31ad0d..da08647323f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -706,6 +706,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an error when clearing the SSGI history texture at creation time (1259930). - Fixed alpha to mask reset when toggling alpha test in the material UI. - Fixed an issue where opening the look dev window with the light theme would make the window blink and eventually crash unity. +- Fixed fallback for ray tracing and light layers (1258837). +- Fixed Sorting Priority not displayed correctly in the DrawRenderers custom pass UI. ### Changed - Improve MIP selection for decals on Transparents @@ -862,6 +864,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Renamed the debug name from SSAO to ScreenSpaceAmbientOcclusion (1254974). - Added missing tooltips and improved the UI of the aperture control (case 1254916). - Fixed wrong tooltips in the Dof Volume (case 1256641). +- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes). ## [7.1.1] - 2019-09-05 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md index 8ed7d3db022..4c6a04bb926 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Pass.md @@ -79,7 +79,7 @@ float4 FullScreenPass(Varyings varyings) : SV_Target // Load the camera color buffer at the mip 0 if we're not at the before rendering injection point if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING) - color = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1); + color = float4(CustomPassLoadCameraColor(varyings.positionCS.xy, 0), 1); // Add your custom pass code here @@ -98,6 +98,7 @@ In this snippet, we fetch a lot of useful input data that you might need in your | **Sampling the camera color with lods is only available in after and before post process passes**. Calling `CustomPassSampleCameraColor` at before rendering will only return black. | | **DrawRenderers Pass chained with FullScreen Pass**: In multi-pass setups where you draw objects in the camera color buffer and then read it from a fullscreen custom pass, you'll not see the objects you've drawn in the passes before your fullscreen pass (unless you are in Before Transparent). | | **MSAA**: When dealing with MSAA, you must check that the `Fetch color buffer` boolean is correctly setup because it will determine whether or not you'll be able to fetch the color buffer in this pass or not. | +| **Before Pre-Refraction and After post-process**: On these injection points, the camera color buffer set as the target for the fullscreen pass is the same as the one you can access inside the shader. Because the camera color buffer is the target, and because of read/write restrictions on certain platforms, you cannot directly sample from the camera color buffer inside the shader. Instead, you need to split your effect into two passes and use the custom color buffer as an intermediate buffer. This avoids reading and writing simultaneously to the same buffer. | ### DrawRenderers Custom Pass diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs index dfcb90d269a..633f0569d3c 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs @@ -161,7 +161,8 @@ protected override void DoPassGUI(SerializedProperty customPass, Rect rect) #endif // TODO: remove all this code when the fix for SerializedReference lands - EditorGUI.PropertyField(rect, m_SortingCriteria, Styles.sortingCriteria); + m_SortingCriteria.intValue = (int)(SortingCriteria)EditorGUI.EnumFlagsField(rect, Styles.sortingCriteria, (SortingCriteria)m_SortingCriteria.intValue); + // EditorGUI.PropertyField(rect, m_SortingCriteria, Styles.sortingCriteria); rect.y += Styles.defaultLineSpace; EditorGUI.indentLevel--; 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 4c74518fddf..b54205ecbc7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -379,6 +379,7 @@ static class HDShaderIDs public static readonly int _CustomDepthTexture = Shader.PropertyToID("_CustomDepthTexture"); public static readonly int _CustomColorTexture = Shader.PropertyToID("_CustomColorTexture"); public static readonly int _CustomPassInjectionPoint = Shader.PropertyToID("_CustomPassInjectionPoint"); + public static readonly int _AfterPostProcessColorBuffer = Shader.PropertyToID("_AfterPostProcessColorBuffer"); public static readonly int _InputCubemap = Shader.PropertyToID("_InputCubemap"); public static readonly int _Mipmap = Shader.PropertyToID("_Mipmap"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl index 00f86e02957..fb5e97ceed7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl @@ -10,6 +10,10 @@ float _CustomPassInjectionPoint; float _FadeValue; +// This texture is only available in after post process and contains the result of post processing effects. +// While SampleCameraColor still returns the color pyramid without post processes +TEXTURE2D_X(_AfterPostProcessColorBuffer); + float3 CustomPassSampleCameraColor(float2 uv, float lod, bool uvGuards = true) { if (uvGuards) @@ -22,6 +26,7 @@ float3 CustomPassSampleCameraColor(float2 uv, float lod, bool uvGuards = true) // Also, we don't use _RTHandleScaleHistory to sample because the color pyramid bound is the actual camera color buffer which is at the resolution of the camera case CUSTOMPASSINJECTIONPOINT_BEFORE_TRANSPARENT: case CUSTOMPASSINJECTIONPOINT_BEFORE_PRE_REFRACTION: return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, 0).rgb; + case CUSTOMPASSINJECTIONPOINT_AFTER_POST_PROCESS: return SAMPLE_TEXTURE2D_X_LOD(_AfterPostProcessColorBuffer, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, 0).rgb; default: return SampleCameraColor(uv, lod); } } @@ -34,6 +39,7 @@ float3 CustomPassLoadCameraColor(uint2 pixelCoords, float lod) // there is no color pyramid yet for before transparent so we can't sample with mips. case CUSTOMPASSINJECTIONPOINT_BEFORE_TRANSPARENT: case CUSTOMPASSINJECTIONPOINT_BEFORE_PRE_REFRACTION: return LOAD_TEXTURE2D_X_LOD(_ColorPyramidTexture, pixelCoords, 0).rgb; + case CUSTOMPASSINJECTIONPOINT_AFTER_POST_PROCESS: return LOAD_TEXTURE2D_X_LOD(_AfterPostProcessColorBuffer, pixelCoords, 0).rgb; default: return LoadCameraColor(pixelCoords, lod); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs index 323b3f55b5d..c622bf946ca 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassVolume.cs @@ -88,6 +88,8 @@ internal bool Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, return false; Shader.SetGlobalFloat(HDShaderIDs._CustomPassInjectionPoint, (float)injectionPoint); + if (injectionPoint == CustomPassInjectionPoint.AfterPostProcess) + Shader.SetGlobalTexture(HDShaderIDs._AfterPostProcessColorBuffer, targets.cameraColorBuffer); foreach (var pass in customPasses) {