diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5004_Pbr_Sky_High_Altitude.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5004_Pbr_Sky_High_Altitude.png index 2b423b45c63..b5182262ac6 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5004_Pbr_Sky_High_Altitude.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5004_Pbr_Sky_High_Altitude.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c723af154dbb7ffcc7eae1c1a5810846517df5c3fbad0aefb0101d318c7fe36f -size 712864 +oid sha256:aa2586bc9a522e81bd7914c5c603d07ef80f85c93d45c452296b3525a7c16838 +size 701578 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5005_Pbr_Sky_Med_Altitude.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5005_Pbr_Sky_Med_Altitude.png index dc99e209b23..ff42408aa5b 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5005_Pbr_Sky_Med_Altitude.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5005_Pbr_Sky_Med_Altitude.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e3296ee5a7447a53b6ca1ff47e1342de52b3e474fe5e3526f43a6bd572480a4 -size 34558 +oid sha256:3b251e69e598fb07a8541dfa06ea7ad5fcd836de08aa00dd09dfc9bf4f885fc0 +size 208550 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5006_Pbr_Sky_Low_Altitude.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5006_Pbr_Sky_Low_Altitude.png index dc99e209b23..ec3a216e548 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5006_Pbr_Sky_Low_Altitude.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/OSXEditor/Metal/None/5006_Pbr_Sky_Low_Altitude.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e3296ee5a7447a53b6ca1ff47e1342de52b3e474fe5e3526f43a6bd572480a4 -size 34558 +oid sha256:e52ec8d9e57626d175f26ce3303ff38abd57b1204543ef0d5e6375b523baae40 +size 74986 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 82ed08476d1..7b4921dcff6 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 @@ -55,7 +55,7 @@ void EvaluatePbrAtmosphere(float3 worldSpaceCameraPos, float3 V, float distAlong // TODO: Not sure it's possible to precompute cam rel pos since variables // in the two constant buffers may be set at a different frequency? - const float3 O = worldSpaceCameraPos - _PlanetCenterPosition; + const float3 O = worldSpaceCameraPos - _PlanetCenterPosition.xyz; const float tFrag = abs(distAlongRay); // Clear the "hit ground" flag float3 N; float r; // These params correspond to the entry point @@ -115,7 +115,7 @@ void EvaluatePbrAtmosphere(float3 worldSpaceCameraPos, float3 V, float distAlong // We may have swapped X and Y. float2 ch = abs(ch0 - ch1); - float3 optDepth = ch.x * H.x * _AirSeaLevelExtinction + float3 optDepth = ch.x * H.x * _AirSeaLevelExtinction.xyz + ch.y * H.y * _AerosolSeaLevelExtinction; skyOpacity = 1 - TransmittanceFromOpticalDepth(optDepth); // from 'tEntry' to 'tFrag' @@ -242,7 +242,7 @@ void EvaluatePbrAtmosphere(float3 worldSpaceCameraPos, float3 V, float distAlong float nrmAngle = Remap01(chiAngle, rcpLen, start * rcpLen); // float angle = saturate((0.5 * PI) - acos(cosChi) * rcp(0.5 * PI)); - skyColor *= ExpLerp(_HorizonTint, _ZenithTint, nrmAngle, _HorizonZenithShiftPower, _HorizonZenithShiftScale); + skyColor *= ExpLerp(_HorizonTint.rgb, _ZenithTint.rgb, nrmAngle, _HorizonZenithShiftPower, _HorizonZenithShiftScale); } } 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 e7269e379a1..706a9e1787b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -201,7 +201,7 @@ float4 EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInpu // TODO: Not sure it's possible to precompute cam rel pos since variables // in the two constant buffers may be set at a different frequency? float3 X = GetAbsolutePositionWS(posInput.positionWS); - float3 C = _PlanetCenterPosition; + float3 C = _PlanetCenterPosition.xyz; float r = distance(X, C); float cosHoriz = ComputeCosineOfHorizonAngle(r); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/InScatteredRadiancePrecomputation.compute b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/InScatteredRadiancePrecomputation.compute index 75d8cd3d558..ee9b7f40823 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/InScatteredRadiancePrecomputation.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/InScatteredRadiancePrecomputation.compute @@ -258,7 +258,7 @@ void main(uint3 dispatchThreadId : SV_DispatchThreadID) float3 gN = normalize(gP); // Shade the ground. - const float3 gBrdf = INV_PI * _GroundAlbedo; + const float3 gBrdf = INV_PI * _GroundAlbedo.rgb; // TODO: we compute the same thing for many voxels, // the only real difference is the phase function... diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl index ab74d59a506..cee55d86c5f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyCommon.hlsl @@ -27,7 +27,7 @@ float DifferenceOfSquares(float a, float b) float3 AirScatter(float height) { - return _AirSeaLevelScattering * exp(-height * _AirDensityFalloff); + return _AirSeaLevelScattering.rgb * exp(-height * _AirDensityFalloff); } float AirPhase(float LdotV) @@ -37,7 +37,7 @@ float AirPhase(float LdotV) float3 AerosolScatter(float height) { - return _AerosolSeaLevelScattering * exp(-height * _AerosolDensityFalloff); + return _AerosolSeaLevelScattering.rgb * exp(-height * _AerosolDensityFalloff); } float AerosolPhase(float LdotV) @@ -285,7 +285,7 @@ float3 ComputeAtmosphericOpticalDepth(float r, float cosTheta, bool aboveHorizon float2 optDepth = ch * H; - return optDepth.x * _AirSeaLevelExtinction + optDepth.y * _AerosolSeaLevelExtinction; + return optDepth.x * _AirSeaLevelExtinction.xyz + optDepth.y * _AerosolSeaLevelExtinction; } float3 ComputeAtmosphericOpticalDepth1(float r, float cosTheta) 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 5f79f09fac6..640191e213c 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 @@ -384,6 +384,7 @@ void UpdateGlobalConstantBuffer(CommandBuffer cmd, BuiltinSkyParameters builtinP m_ConstantBuffer._AerosolAnisotropy = pbrSky.aerosolAnisotropy.value; m_ConstantBuffer._AerosolPhasePartConstant = CornetteShanksPhasePartConstant(pbrSky.aerosolAnisotropy.value); m_ConstantBuffer._Unused = 0.0f; // Warning fix + m_ConstantBuffer._Unused2 = 0.0f; // Warning fix m_ConstantBuffer._AirDensityFalloff = 1.0f / airH; m_ConstantBuffer._AirScaleHeight = airH; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs index a9f62b941b8..7e8ba755c84 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs @@ -32,25 +32,22 @@ unsafe struct ShaderVariablesPhysicallyBasedSky public float _AerosolDensityFalloff; public float _AerosolScaleHeight; - public Vector3 _AirSeaLevelExtinction; - public float _AerosolSeaLevelExtinction; + public Vector4 _AirSeaLevelExtinction; + public Vector4 _AirSeaLevelScattering; + public Vector4 _AerosolSeaLevelScattering; + public Vector4 _GroundAlbedo; + public Vector4 _PlanetCenterPosition; // Not used during the precomputation, but needed to apply the atmospheric effect + public Vector4 _HorizonTint; + public Vector4 _ZenithTint; - public Vector3 _AirSeaLevelScattering; + public float _AerosolSeaLevelExtinction; public float _IntensityMultiplier; - - public Vector3 _AerosolSeaLevelScattering; public float _ColorSaturation; - - public Vector3 _GroundAlbedo; public float _AlphaSaturation; - public Vector3 _PlanetCenterPosition; // Not used during the precomputation, but needed to apply the atmospheric effect public float _AlphaMultiplier; - - public Vector3 _HorizonTint; public float _HorizonZenithShiftPower; - - public Vector3 _ZenithTint; public float _HorizonZenithShiftScale; + public float _Unused2; } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs.hlsl index 4ea7a08d2cf..b7df04f15ca 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/ShaderVariablesPhysicallyBasedSky.cs.hlsl @@ -28,20 +28,21 @@ GLOBAL_CBUFFER_START(ShaderVariablesPhysicallyBasedSky, b2) float _AirScaleHeight; float _AerosolDensityFalloff; float _AerosolScaleHeight; - float3 _AirSeaLevelExtinction; + float4 _AirSeaLevelExtinction; + float4 _AirSeaLevelScattering; + float4 _AerosolSeaLevelScattering; + float4 _GroundAlbedo; + float4 _PlanetCenterPosition; + float4 _HorizonTint; + float4 _ZenithTint; float _AerosolSeaLevelExtinction; - float3 _AirSeaLevelScattering; float _IntensityMultiplier; - float3 _AerosolSeaLevelScattering; float _ColorSaturation; - float3 _GroundAlbedo; float _AlphaSaturation; - float3 _PlanetCenterPosition; float _AlphaMultiplier; - float3 _HorizonTint; float _HorizonZenithShiftPower; - float3 _ZenithTint; float _HorizonZenithShiftScale; + float _Unused2; CBUFFER_END