diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/112_Reflection_AlternativeSGNodes.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/112_Reflection_AlternativeSGNodes.png index 42363847d70..f8ccffd35d6 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/112_Reflection_AlternativeSGNodes.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/112_Reflection_AlternativeSGNodes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3dbd076f38b123f9dd96db53fa3b6a8383570c90e1d43b50a94cfdbcb4d30372 -size 44327 +oid sha256:a1e67a64d5a24a8234e44badfc551f2b250825ef0a344db9b663a6874b613735 +size 38299 diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 2bf2a73ac9d..1ccfed8071b 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Fixed issue when changing volume profiles at runtime with a script (case 1364256). +- Fixed XR support in CoreUtils.DrawFullscreen function. +- Fixed an issue causing Render Graph execution errors after a random amount of time. ## [13.1.1] - 2021-10-04 diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs index 1d7c1525709..1b1d27dc5f8 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs @@ -378,6 +378,8 @@ void OnGUI() if (GUILayout.Button(Styles.resetButtonContent, EditorStyles.toolbarButton)) { DebugManager.instance.Reset(); + DestroyWidgetStates(); + UpdateWidgetStates(); InternalEditorUtility.RepaintAllViews(); } diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs index 59df7385116..3581e2f2c9a 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeEditor.cs @@ -67,7 +67,7 @@ void RefreshEffectListEditor(VolumeProfile asset) { m_ComponentList.Clear(); - asset.Sanitize(); + asset?.Sanitize(); if (asset != null) m_ComponentList.Init(asset, new SerializedObject(asset)); diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs b/com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs index c89b18e3e45..1c787012002 100644 --- a/com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs @@ -19,11 +19,12 @@ class DebugUpdater : MonoBehaviour bool m_RuntimeUiWasVisibleLastFrame = false; [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] - [Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")] static void RuntimeInit() { +#if DEVELOPMENT_BUILD || UNITY_EDITOR if (DebugManager.instance.enableRuntimeUI) EnableRuntime(); +#endif } internal static void SetEnabled(bool enabled) diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs index 6577d4b28b1..673e9ea0eb2 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs @@ -48,14 +48,21 @@ public bool IsValid() static public void NewFrame(int executionIndex) { + uint previousValidBit = s_CurrentValidBit; // Scramble frame count to avoid collision when wrapping around. s_CurrentValidBit = (uint)(((executionIndex >> 16) ^ (executionIndex & 0xffff) * 58546883) << 16); // In case the current valid bit is 0, even though perfectly valid, 0 represents an invalid handle, hence we'll // trigger an invalid state incorrectly. To account for this, we actually skip 0 as a viable s_CurrentValidBit and // start from 1 again. - if (s_CurrentValidBit == 0) + // In the same spirit, s_SharedResourceValidBit is reserved for shared textures so we should never use it otherwise + // resources could be considered valid at frame N+1 (because shared) even though they aren't. + if (s_CurrentValidBit == 0 || s_CurrentValidBit == s_SharedResourceValidBit) { - s_CurrentValidBit = 1 << 16; + // We need to make sure we don't pick the same value twice. + uint value = 1; + while (previousValidBit == (value << 16)) + value++; + s_CurrentValidBit = (value << 16); } } } diff --git a/com.unity.render-pipelines.core/Runtime/Utilities/CameraCaptureBridge.cs b/com.unity.render-pipelines.core/Runtime/Utilities/CameraCaptureBridge.cs index 162b9d4b443..45145156d6d 100644 --- a/com.unity.render-pipelines.core/Runtime/Utilities/CameraCaptureBridge.cs +++ b/com.unity.render-pipelines.core/Runtime/Utilities/CameraCaptureBridge.cs @@ -35,7 +35,7 @@ public static bool enabled /// Enumeration of actions public static IEnumerator> GetCaptureActions(Camera camera) { - if (!actionDict.TryGetValue(camera, out var actions)) + if (!actionDict.TryGetValue(camera, out var actions) || actions.Count == 0) return null; return actions.GetEnumerator(); diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index 904d87dcc42..fa8aad49498 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -299,6 +299,19 @@ public override int GetHashCode() } } + /// + /// Returns true if any of the volume properites has been overridden. + /// + /// True if any of the volume properites has been overridden. + public bool AnyPropertiesIsOverridden() + { + for (int i = 0; i < parameters.Count; ++i) + { + if (parameters[i].overrideState) return true; + } + return false; + } + /// /// Unity calls this method before the object is destroyed. /// diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 5a3aa4ee11e..b6cc0063723 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -38,7 +38,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed for screen space overlay rendered by camera when HDR is disabled. - Fixed dirtiness handling in path tracing, when using multiple cameras at once (case 1376940). - Fixed taa jitter for after post process materials (case 1380967). -- Fixed a shader warning in the volumetric clouds combine file. +- Fixed rasterized accumulation motion blur when DoF is enabled (case 1378497). +- Fixed light mode not available after switching a light to area "Disc" or "Tube" (case 1372588). +- Fixed CoC size computation when dynamic resolution is enabled +- Fixed shadow cascade transition not working properly with bias. +- Fixed broken rendering when duplicating a camera while the Rendering Debugger is opened. +- Fixed screen space shadow debug view not showing when no shadows is available. +- Fixed nullref from debug menu in release build (case 1381556). +- Fixed debug window reset. +- Fixed camera bridge action in release build (case 1367866). +- Fixed contact shadow disappearing when shadowmask is used and no non-static object is available. +- Fixed atmospheric scattering being incorrectly enabled when scene lighting is disabled. +- Fixed for changes of color curves not being applied immediately. ## [13.1.2] - 2021-11-05 diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs index 242cf2b3733..1aa91e6db26 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -227,7 +227,7 @@ static void DrawGeneralContent(SerializedHDLight serialized, Editor owner, bool EditorGUI.showMixedValue = false; // Draw the mode, for Tube and Disc lights, there is only one choice, so we can disable the enum. - using (new EditorGUI.DisabledScope(serialized.areaLightShape == AreaLightShape.Tube || serialized.areaLightShape == AreaLightShape.Disc)) + using (new EditorGUI.DisabledScope(updatedLightType == HDLightType.Area && (serialized.areaLightShape == AreaLightShape.Tube || serialized.areaLightShape == AreaLightShape.Disc))) serialized.settings.DrawLightmapping(); if (updatedLightType == HDLightType.Area) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl index a4a651e75cd..95ca356e178 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/AtmosphericScattering/AtmosphericScattering.hlsl @@ -257,7 +257,7 @@ void EvaluateAtmosphericScattering(PositionInputs posInput, float3 V, out float3 #ifdef DEBUG_DISPLAY // Don't sample atmospheric scattering when lighting debug more are enabled so fog is not visible - if (_DebugLightingMode >= DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING && _DebugLightingMode <= DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING) + if (_DebugLightingMode == DEBUGLIGHTINGMODE_MATCAP_VIEW || (_DebugLightingMode >= DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING && _DebugLightingMode <= DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING)) return; if (_DebugShadowMapMode == SHADOWMAPDEBUGMODE_SINGLE_SHADOW || _DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER || _DebugLightingMode == DEBUGLIGHTINGMODE_LUMINANCE_METER) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs index 6161bf7f537..2f24a43267e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.Jobs.cs @@ -683,6 +683,12 @@ private void ConvertDirectionalLightToGPUFormat( lightData.flareSize = Mathf.Max(lightRenderData.flareSize * Mathf.Deg2Rad, 5.960464478e-8f); lightData.flareFalloff = lightRenderData.flareFalloff; + + // On some vendors trigonometry has very bad precision, so we precompute what we can on CPU to avoid precision issues (case 1369376). + float radInner = 0.5f * lightData.angularDiameter; + lightData.flareCosInner = Mathf.Cos(radInner); + lightData.flareCosOuter = Mathf.Cos(radInner + lightData.flareSize); + lightData.flareTint = (Vector3)(Vector4)lightRenderData.flareTint; lightData.surfaceTint = (Vector3)(Vector4)lightRenderData.surfaceTint; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs index 9ce11ff3063..1bce684050a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs @@ -225,7 +225,8 @@ private void GetContactShadowMask(HDAdditionalLightData hdAdditionalLightData, B return; // Evaluate the contact shadow index of this light - contactShadowMask = 1 << m_ContactShadowIndex++; + contactShadowMask = 1 << m_ContactShadowIndex; + m_ContactShadowIndex++; // Update the index for next light that will need to cast contact shadows. // If this light has ray traced contact shadow if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && hdAdditionalLightData.rayTraceContactShadow) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs index 60ac297011c..03d4c59d05a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs @@ -99,12 +99,16 @@ struct DirectionalLightData public float diffuseDimmer; public float specularDimmer; + public float penumbraTint; public float isRayTracedContactShadow; public float distanceFromCamera; // -1 -> no sky interaction public float angularDiameter; // Units: radians + public float flareFalloff; + public float flareCosInner; + public float flareCosOuter; public float __unused__; public Vector3 flareTint; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl index bbf1e994bc2..f6a26c97c57 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl @@ -80,6 +80,8 @@ struct DirectionalLightData float distanceFromCamera; float angularDiameter; float flareFalloff; + float flareCosInner; + float flareCosOuter; float __unused__; float3 flareTint; float flareSize; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl index e96e06bb597..05f1a8b3dfd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -190,7 +190,7 @@ float4 EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInpu // Height fog attenuation. { // TODO: should probably unify height attenuation somehow... - float cosZenithAngle = L.y; + float cosZenithAngle = max(L.y, 0.001f); float fragmentHeight = posInput.positionWS.y; float3 oDepth = OpticalDepthHeightFog(_HeightFogBaseExtinction, _HeightFogBaseHeight, _HeightFogExponents, cosZenithAngle, fragmentHeight); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute index ab84a489b27..4be74166151 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.compute @@ -200,9 +200,9 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId // Do the contact shadow for the directional light if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL) { - if (_DirectionalShadowIndex >= 0) + for (uint i = 0; i < _DirectionalLightCount; ++i) { - DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; + DirectionalLightData light = _DirectionalLightDatas[i]; if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 0.0) { @@ -214,6 +214,7 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId // we take full bits at one multiplied by contact shadow and filter the bit at the contact shadow index. contactShadowMask |= light.contactShadowMask * occluded; } + } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs index 836f6f5a049..bacc8459589 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs @@ -481,7 +481,11 @@ TextureHandle RenderScreenSpaceShadows(RenderGraph renderGraph, HDCamera hdCamer // If screen space shadows are not supported for this camera, we are done bool validConditions = hdCamera.frameSettings.IsEnabled(FrameSettingsField.ScreenSpaceShadows) && RequestedScreenSpaceShadows(); if (!validConditions) + { + // We push the debug texture anyway if we are not evaluating any screen space shadows. + PushFullScreenDebugTexture(m_RenderGraph, m_RenderGraph.defaultResources.whiteTextureXR, FullScreenDebugMode.ScreenSpaceShadows); return m_RenderGraph.defaultResources.blackTextureArrayXR; + } using (new RenderGraphProfilingScope(renderGraph, ProfilingSampler.Get(HDProfileId.ScreenSpaceShadows))) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl index 99c0a95b059..0e08873fe78 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl @@ -265,6 +265,7 @@ float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, T positionWS = basePositionWS + sd.cacheTranslationDelta.xyz; /* normal based bias */ + float worldTexelSize = sd.worldTexelSize; float3 orig_pos = positionWS; float3 normalBias = EvalShadow_NormalBias(sd.worldTexelSize, sd.normalBias, normalWS); positionWS += normalBias; @@ -283,6 +284,11 @@ float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, T if (alpha > 0.0) { LoadDirectionalShadowDatas(sd, shadowContext, index + shadowSplitIndex); + + // We need to modify the bias as the world texel size changes between splits and an update is needed. + float biasModifier = (sd.worldTexelSize / worldTexelSize); + normalBias *= biasModifier; + float3 evaluationPosWS = basePositionWS + sd.cacheTranslationDelta.xyz + normalBias; float3 posNDC; posTC = EvalShadow_GetTexcoordsAtlas(sd, _CascadeShadowAtlasSize.zw, evaluationPosWS, posNDC, false); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs index 046ede549ba..6c9b4784ec2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDAdditionalCameraData.cs @@ -690,6 +690,11 @@ void OnEnable() m_Camera.allowMSAA = false; // We don't use this option in HD (it is legacy MSAA) and it produce a warning in the inspector UI if we let it m_Camera.allowHDR = false; + // By doing that, we force the update of frame settings debug data once. Otherwise, when the Rendering Debugger is opened, + // Wrong data is registered to the undo system because it did not get the chance to be updated once. + FrameSettings dummy = new FrameSettings(); + FrameSettingsHistory.AggregateFrameSettings(ref dummy, m_Camera, this, HDRenderPipeline.currentAsset, null); + RegisterDebug(); #if UNITY_EDITOR diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 81f038c5860..93168de2d92 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -1395,6 +1395,8 @@ public ScreenSpaceReflectionAlgorithm MaterialPropertyBlock m_RecorderPropertyBlock = new MaterialPropertyBlock(); Rect? m_OverridePixelRect = null; + internal bool hasCaptureActions => m_RecorderCaptureActions != null; + // Keep track of the previous DLSS state private DynamicResolutionHandler.UpsamplerScheduleType m_PrevUpsamplerSchedule = DynamicResolutionHandler.UpsamplerScheduleType.AfterPost; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs index 37c1c189c4f..20f5fde2f9a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs @@ -538,6 +538,11 @@ TextureHandle RenderPostProcess(RenderGraph renderGraph, source = DepthOfFieldPass(renderGraph, hdCamera, depthBuffer, motionVectors, depthBufferMipChain, source, depthMinMaxAvgMSAA, prepassOutput.stencilBuffer); + if (m_DepthOfField.IsActive() && m_SubFrameManager.isRecording && m_SubFrameManager.subFrameCount > 1) + { + RenderAccumulation(m_RenderGraph, hdCamera, source, source, false); + } + // Motion blur after depth of field for aesthetic reasons (better to see motion // blurred bokeh rather than out of focus motion blur) source = MotionBlurPass(renderGraph, hdCamera, depthBuffer, motionVectors, source); @@ -2716,9 +2721,9 @@ static void DoPhysicallyBasedDepthOfField(in DepthOfFieldParameters dofParameter // The sensor scale is used to convert the CoC size from mm to screen pixels float sensorScale; if (dofParameters.camera.camera.gateFit == Camera.GateFitMode.Horizontal) - sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.x) * dofParameters.camera.camera.pixelWidth; + sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.x) * dofParameters.camera.actualWidth; else - sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.y) * dofParameters.camera.camera.pixelHeight; + sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.y) * dofParameters.camera.actualHeight; // "A Lens and Aperture Camera Model for Synthetic Image Generation" [Potmesil81] // Note: Focus distance is in meters, but focalLength and sensor size are in mm. @@ -4301,7 +4306,8 @@ TextureHandle ColorGradingPass(RenderGraph renderGraph) var currentGradingHash = ComputeLUTHash(); // The lut we have already is ok. - if (currentGradingHash == m_LutHash) + if (currentGradingHash == m_LutHash && + !m_Curves.AnyPropertiesIsOverridden()) // Curves content are not hashed, to compute the hash of the curves would probably be more expensive than actually running the LUT pass. So we just check if the project is using anything but the default return logLut; // Else we update the hash and we recompute the LUT. 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 22f04d1b9e6..2adf5920002 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 @@ -240,7 +240,8 @@ void RecordRenderGraph(RenderRequest renderRequest, PushFullScreenDebugTexture(m_RenderGraph, colorBuffer, FullScreenDebugMode.WorldSpacePosition, fullScreenDebugFormat); PushFullScreenLightingDebugTexture(m_RenderGraph, colorBuffer, fullScreenDebugFormat); - if (m_SubFrameManager.isRecording && m_SubFrameManager.subFrameCount > 1) + bool accumulateInPost = m_PostProcessEnabled && m_DepthOfField.IsActive(); + if (!accumulateInPost && m_SubFrameManager.isRecording && m_SubFrameManager.subFrameCount > 1) { RenderAccumulation(m_RenderGraph, hdCamera, colorBuffer, colorBuffer, false); } 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 e4a69f8727b..b09e3659968 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -584,7 +584,6 @@ static class HDShaderIDs public static readonly int _SpaceEmissionMultiplier = Shader.PropertyToID("_SpaceEmissionMultiplier"); public static readonly int _RenderSunDisk = Shader.PropertyToID("_RenderSunDisk"); - public static readonly int _SunDiskCosines = Shader.PropertyToID("_SunDiskCosines"); public static readonly int _ColorSaturation = Shader.PropertyToID("_ColorSaturation"); public static readonly int _AlphaSaturation = Shader.PropertyToID("_AlphaSaturation"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RayTracingContactShadow.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RayTracingContactShadow.raytrace index ac35c50d795..c1bac5a59ad 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RayTracingContactShadow.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RayTracingContactShadow.raytrace @@ -94,10 +94,9 @@ void RayGenContactShadows() uint contactShadowMask = 0; UnpackContactShadowData(_ContactShadowTextureUAV[COORD_TEXTURE2D_X(pixelCoord)], fade, contactShadowMask); - // Let's first process the directional shadow - if (_DirectionalShadowIndex >= 0) + for (int i = 0; i < _DirectionalLightCount; ++i) { - DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; + DirectionalLightData light = _DirectionalLightDatas[i]; if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 1.0) { 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 9f46f0dfd17..97045abbfda 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 @@ -905,7 +905,7 @@ internal static bool PostProcessIsFinalPass(HDCamera hdCamera) // Post process pass is the final blit only when not in developer mode. // In developer mode, we support a range of debug rendering that needs to occur after post processes. // In order to simplify writing them, we don't Y-flip in the post process pass but add a final blit at the end of the frame. - return !Debug.isDebugBuild && !WillCustomPassBeExecuted(hdCamera, CustomPassInjectionPoint.AfterPostProcess); + return !Debug.isDebugBuild && !WillCustomPassBeExecuted(hdCamera, CustomPassInjectionPoint.AfterPostProcess) && !hdCamera.hasCaptureActions; } // These two convertion functions are used to store GUID assets inside materials, 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 4dfea227c0e..98e859f9ff6 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 @@ -4,6 +4,7 @@ Shader "Hidden/HDRP/Sky/PbrSky" #pragma vertex Vert + // #pragma enable_d3d11_debug_symbols #pragma editor_sync_compilation #pragma target 4.5 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch @@ -25,13 +26,6 @@ Shader "Hidden/HDRP/Sky/PbrSky" float _GroundEmissionMultiplier; float _SpaceEmissionMultiplier; - // Inner and outer cosine computed as: - // float radInner = 0.5 * light.angularDiameter - // float cosInner = cos(radInner); // (In _SunDiskCosines.x) - // float cosOuter = cos(radInner + light.flareSize); // (In _SunDiskCosines.y) - // We need to pass it over instead of computing it here because on some vendors trigonometry has very bad precision, so we precompute what we can on CPU to have better precision. - float4 _SunDiskCosines; - // Sky framework does not set up global shader variables (even per-view ones), // so they can contain garbage. It's very difficult to not include them, however, // since the sky framework includes them internally in many header files. @@ -118,19 +112,16 @@ Shader "Hidden/HDRP/Sky/PbrSky" float rad = acos(LdotV); float radInner = 0.5 * light.angularDiameter; - float cosInner = _SunDiskCosines.x; - float cosOuter = _SunDiskCosines.y; - - float solidAngle = TWO_PI * (1 - cosInner); + float solidAngle = TWO_PI * (1 - light.flareCosInner); - if (LdotV >= cosOuter) + if (LdotV >= light.flareCosOuter) { // Sun flare is visible. Sun disk may or may not be visible. // Assume uniform emission. float3 color = light.color.rgb; float scale = rcp(solidAngle); - if (LdotV >= cosInner) // Sun disk. + if (LdotV >= light.flareCosInner) // Sun disk. { tFrag = lightDist; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs index 54898c0321b..19ebc2d518d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs @@ -500,14 +500,6 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo } s_PbrSkyMaterialProperties.SetInt(HDShaderIDs._HasSpaceEmissionTexture, hasSpaceEmissionTexture); - // We need to pass it over instead of computing it here because on some vendors trigonometry has very bad precision, so we precompute what we can on CPU to have better precision. - // We can safely retrieve HDAdditionalLightData as for PBR sky the sunlight is always going to be an HDRP light. - var lightData = builtinParams.sunLight.gameObject.GetComponent(); - float radInner = 0.5f * lightData.angularDiameter * Mathf.Deg2Rad; - float cosInner = Mathf.Cos(radInner); - float cosOuter = Mathf.Cos(radInner + lightData.flareSize); - s_PbrSkyMaterialProperties.SetVector(HDShaderIDs._SunDiskCosines, new Vector4(cosInner, cosOuter, 0, 0)); - s_PbrSkyMaterialProperties.SetInt(HDShaderIDs._RenderSunDisk, renderSunDisk ? 1 : 0); int pass = (renderForCubemap ? 0 : 2); diff --git a/com.unity.template-hd/Assets/Scenes/SampleScene.unity b/com.unity.template-hd/Assets/Scenes/SampleScene.unity index e73ae786441..fe71edce88c 100644 --- a/com.unity.template-hd/Assets/Scenes/SampleScene.unity +++ b/com.unity.template-hd/Assets/Scenes/SampleScene.unity @@ -28899,9 +28899,9 @@ MonoBehaviour: m_UseScreenSpaceShadows: 0 m_InteractsWithSky: 1 m_AngularDiameter: 0.53 - m_FlareSize: 0 - m_FlareTint: {r: 0, g: 0, b: 0, a: 1} - m_FlareFalloff: 0 + m_FlareSize: 2 + m_FlareTint: {r: 1, g: 1, b: 1, a: 1} + m_FlareFalloff: 4 m_SurfaceTexture: {fileID: 0} m_SurfaceTint: {r: 1, g: 1, b: 1, a: 1} m_Distance: 150000000