diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 14f9d78aef5..d9cd68709ee 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Changed the clamping approach for RTR and RTGI (in both perf and quality) to improve visual quality. - Changed the warning message for ray traced area shadows (case 1303410). - Disabled specular occlusion for what we consider medium and larger scale ao > 1.25 with a 25cm falloff interval. +- Removed backplate from rendering of lighting cubemap as it did not really work conceptually and caused artefacts. ## [10.3.0] - 2020-12-01 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md index 2d3683706f1..dfe0e97852a 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Override-HDRI-Sky.md @@ -65,4 +65,6 @@ These properties only appear if you enable [more options](More-Options.md). | -**Shadow Tint** | Specifies the color to tint shadows cast onto the backplate. | | - **Reset Color** | Resets the saved **Shadow Tint** for the shadow. HDRP calculates a new default shadow tint when the HDRI changes. | -**Note**: To use ambient occlusion in the backplate, increase the value of the **Direct Lighting Strength** property on the [Ambient Occlusion](Override-Ambient-Occlusion.md) component override. As the backplate does not have global illumination, it can only get ambient occlusion from direct lighting. \ No newline at end of file +**Note**: To use ambient occlusion in the backplate, increase the value of the **Direct Lighting Strength** property on the [Ambient Occlusion](Override-Ambient-Occlusion.md) component override. As the backplate does not have global illumination, it can only get ambient occlusion from direct lighting. + +**Limitation**: The backplate don't affect the Sky lighting (Sky Reflection / Ligthmaps / LightProbes / Ambient Probe). It will not appear with the default sky reflection but only in local reflection probes. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader index 6920dd77836..48f79b2a2a3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader @@ -310,11 +310,6 @@ Shader "Hidden/HDRP/Sky/HDRISky" return results; } - float4 FragBakingBackplate(Varyings input) : SV_Target - { - return RenderBackplate(input, 1.0); - } - float4 FragRenderBackplate(Varyings input) : SV_Target { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); @@ -338,12 +333,6 @@ Shader "Hidden/HDRP/Sky/HDRISky" return depth; } - float FragBakingBackplateDepth(Varyings input) : SV_Depth - { - UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); - return GetDepthWithBackplate(input); - } - float4 FragRenderBackplateDepth(Varyings input, out float depth : SV_Depth) : SV_Target0 { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); @@ -392,20 +381,6 @@ Shader "Hidden/HDRP/Sky/HDRISky" ENDHLSL } - // HDRI Sky with Backplate - // For cubemap with Backplate - Pass - { - ZWrite Off - ZTest Always - Blend Off - Cull Off - - HLSLPROGRAM - #pragma fragment FragBakingBackplate - ENDHLSL - } - // For fullscreen Sky with Backplate Pass { @@ -419,20 +394,6 @@ Shader "Hidden/HDRP/Sky/HDRISky" ENDHLSL } - // HDRI Sky with Backplate for PreRenderSky (Depth Only Pass) - // DepthOnly For cubemap with Backplate - Pass - { - ZWrite On - ZTest LEqual - Blend Off - Cull Off - - HLSLPROGRAM - #pragma fragment FragBakingBackplateDepth - ENDHLSL - } - // DepthOnly For fullscreen Sky with Backplate Pass { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISkyRenderer.cs index db4cca4e8b9..809f64f1102 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISkyRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISkyRenderer.cs @@ -13,10 +13,8 @@ class HDRISkyRenderer : SkyRenderer private static int m_RenderCubemapID = 0; // FragBaking private static int m_RenderFullscreenSkyID = 1; // FragRender - private static int m_RenderCubemapWithBackplateID = 2; // FragBakingBackplate - private static int m_RenderFullscreenSkyWithBackplateID = 3; // FragRenderBackplate - private static int m_RenderDepthOnlyCubemapWithBackplateID = 4; // FragBakingBackplateDepth - private static int m_RenderDepthOnlyFullscreenSkyWithBackplateID = 5; // FragRenderBackplateDepth + private static int m_RenderFullscreenSkyWithBackplateID = 2; // FragRenderBackplate + private static int m_RenderDepthOnlyFullscreenSkyWithBackplateID = 3; // FragRenderBackplateDepth public HDRISkyRenderer() { @@ -92,16 +90,10 @@ public override bool RequiresPreRenderSky(BuiltinSkyParameters builtinParams) return hdriSky.enableBackplate.value; } - public override void PreRenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk) + public override void PreRenderSky(BuiltinSkyParameters builtinParams) { var hdriSky = builtinParams.skySettings as HDRISky; - int passID; - if (renderForCubemap) - passID = m_RenderDepthOnlyCubemapWithBackplateID; - else - passID = m_RenderDepthOnlyFullscreenSkyWithBackplateID; - float intensity, phi, backplatePhi; GetParameters(out intensity, out phi, out backplatePhi, builtinParams, hdriSky); @@ -113,7 +105,7 @@ public override void PreRenderSky(BuiltinSkyParameters builtinParams, bool rende m_PropertyBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix); - CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_SkyHDRIMaterial, m_PropertyBlock, passID); + CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_SkyHDRIMaterial, m_PropertyBlock, m_RenderDepthOnlyFullscreenSkyWithBackplateID); } } @@ -123,19 +115,20 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo float intensity, phi, backplatePhi; GetParameters(out intensity, out phi, out backplatePhi, builtinParams, hdriSky); int passID; - if (hdriSky.enableBackplate.value == false) + if (renderForCubemap) { - if (renderForCubemap) - passID = m_RenderCubemapID; - else - passID = m_RenderFullscreenSkyID; + passID = m_RenderCubemapID; } else { - if (renderForCubemap) - passID = m_RenderCubemapWithBackplateID; + if (hdriSky.enableBackplate.value == false) + { + passID = m_RenderFullscreenSkyID; + } else + { passID = m_RenderFullscreenSkyWithBackplateID; + } } if (hdriSky.enableDistortion.value == true) @@ -182,6 +175,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo shadowFilter |= unchecked((uint)LightFeatureFlags.Area); m_SkyHDRIMaterial.SetInt(HDShaderIDs._BackplateShadowFilter, unchecked((int)shadowFilter)); + // This matrix needs to be updated at the draw call frequency. m_PropertyBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix); CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_SkyHDRIMaterial, m_PropertyBlock, passID); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs index d66cca43514..9be57947a74 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -325,8 +325,6 @@ public void Build(HDRenderPipelineAsset hdAsset, RenderPipelineResources default m_SkyboxBSDFCubemapIntermediate = RTHandles.Alloc(resolution, resolution, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureDimension.Cube, useMipMap: true, autoGenerateMips: false, filterMode: FilterMode.Trilinear, name: "SkyboxBSDFIntermediate"); m_CubemapScreenSize = new Vector4((float)resolution, (float)resolution, 1.0f / (float)resolution, 1.0f / (float)resolution); - var cubeProj = Matrix4x4.Perspective(90.0f, 1.0f, 0.01f, 1.0f); - for (int i = 0; i < 6; ++i) { var lookAt = Matrix4x4.LookAt(Vector3.zero, CoreUtils.lookAtList[i], CoreUtils.upVectorList[i]); @@ -962,7 +960,7 @@ public void PreRenderSky(HDCamera hdCamera, Light sunLight, RTHandle colorBuffer } if (preRenderSky) - skyContext.skyRenderer.PreRenderSky(m_BuiltinParameters, false, hdCamera.camera.cameraType != CameraType.Reflection || skyContext.skySettings.includeSunInBaking.value); + skyContext.skyRenderer.PreRenderSky(m_BuiltinParameters); if (skyContext.HasClouds() && skyContext.cloudRenderer.RequiresPreRenderClouds(m_BuiltinParameters)) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs index d7592eef990..2e7d3fb760a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderer.cs @@ -33,7 +33,18 @@ public abstract class SkyRenderer /// Engine parameters that you can use to render the sky. /// Pass in true if you want to render the sky into a cubemap for lighting. This is useful when the sky renderer needs a different implementation in this case. /// If the sky renderer supports the rendering of a sun disk, it must not render it if this is set to false. - public virtual void PreRenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk) {} + [System.Obsolete("Please override PreRenderSky(BuiltinSkyParameters) instead.")] + public virtual void PreRenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk) + { + PreRenderSky(builtinParams); + } + + /// + /// Preprocess for rendering the sky. Called before the DepthPrePass operations + /// + /// Engine parameters that you can use to render the sky. + public virtual void PreRenderSky(BuiltinSkyParameters builtinParams) {} + /// /// Whether the PreRenderSky step is required.