diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 7189925eb13..6610ee97db3 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -1,4 +1,4 @@ -# Changelog +# Changelog All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) @@ -866,6 +866,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - 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). +- PBR Sky now doesn't go black when going below sea level, but it instead freezes calculation as if on the horizon. ## [7.1.1] - 2019-09-05 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 640191e213c..01c708534ba 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 @@ -443,11 +443,13 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo var pbrSky = builtinParams.skySettings as PhysicallyBasedSky; // TODO: the following expression is somewhat inefficient, but good enough for now. - Vector3 X = builtinParams.worldSpaceCameraPos; - float r = Vector3.Distance(X, pbrSky.GetPlanetCenterPosition(X)); - float R = pbrSky.GetPlanetaryRadius(); + Vector3 cameraPos = builtinParams.worldSpaceCameraPos; + Vector3 planetCenter = pbrSky.GetPlanetCenterPosition(cameraPos); + float R = pbrSky.GetPlanetaryRadius(); - bool isPbrSkyActive = r > R; // Disable sky rendering below the ground + Vector3 cameraToPlanetCenter = planetCenter - cameraPos; + float r = cameraToPlanetCenter.magnitude; + cameraPos = planetCenter - Mathf.Max(R, r) * cameraToPlanetCenter.normalized; CommandBuffer cmd = builtinParams.commandBuffer; @@ -461,7 +463,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo pbrSky.spaceRotation.value.z); s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix); - s_PbrSkyMaterialProperties.SetVector(HDShaderIDs._WorldSpaceCameraPos1, builtinParams.worldSpaceCameraPos); + s_PbrSkyMaterialProperties.SetVector(HDShaderIDs._WorldSpaceCameraPos1, cameraPos); s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._ViewMatrix1, builtinParams.viewMatrix); s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._PlanetRotation, Matrix4x4.Rotate(planetRotation)); s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._SpaceRotation, Matrix4x4.Rotate(spaceRotation)); @@ -499,7 +501,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo s_PbrSkyMaterialProperties.SetInt(HDShaderIDs._RenderSunDisk, renderSunDisk ? 1 : 0); - int pass = (renderForCubemap ? 0 : 2) + (isPbrSkyActive ? 0 : 1); + int pass = (renderForCubemap ? 0 : 2); CloudLayer.Apply(builtinParams.cloudLayer, m_PbrSkyMaterial);