diff --git a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXCommon.hlsl index 78684f3182c..023c1131603 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXCommon.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXCommon.hlsl @@ -118,11 +118,6 @@ float VFXSampleDepth(float4 posSS) return LoadCameraDepth(posSS.xy); } -float VFXLinearEyeDepth(float depth) -{ - return LinearEyeDepth(depth,_ZBufferParams); -} - void VFXApplyShadowBias(inout float4 posCS, inout float3 posWS, float3 normalWS) { } diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index bdde8bf52a5..4c7aa1660a4 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed artifacts in Speed Tree 8 billboard LODs due to SpeedTree LOD smoothing/crossfading [case 1348407] - Fixed an issue where the scene view would turn black when bloom was enabled. [case 1298790](https://issuetracker.unity3d.com/issues/urp-bloom-and-tonemapping-causes-the-screen-to-go-black-in-scene-mode), [case 1340848](https://issuetracker.unity3d.com/issues/urp-bloom-produces-visual-artifacts-when-color-slash-emission-are-not-clamped) - Fixed a case where camera dimension can be zero. [case 1321168](https://issuetracker.unity3d.com/issues/urp-attempting-to-get-camera-relative-temporary-rendertexture-is-thrown-when-tweening-the-viewport-rect-values-of-a-camera) +- VFX: Fixed soft particles when HDR or Opaque texture isn't enabled +- VFX: Fixed OpenGL soft particles fallback when depth texture isn't available ## [10.6.0] - 2021-04-29 diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index 6320df91578..d99dab96953 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [10.7.0] - 2021-07-02 ### Fixed - Removed shader warnings due to SAMPLE_DEPTH_TEXTURE redefinition [Case 1331262](https://issuetracker.unity3d.com/product/unity/issues/guid/1331262/) +- Fix Soft Particle depth computation when using an orthographic camera [Case 1309961](https://issuetracker.unity3d.com/product/unity/issues/guid/1309961) ## [10.6.0] - 2021-04-29 @@ -62,8 +63,6 @@ The version number for this package has increased due to a version update of a r ### Added - Added new setting to output nodes to exclude from TAA - New Sample Point cache & Sample Attribute map operators - -### Changed - Changed the "Edit" button so it becomes "New" when no asset is set on a Visual Effect component, in order to save a new visual effect graph asset. ### Fixed diff --git a/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.hlsl b/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.hlsl index ebf560bcd28..e9cd9f3c701 100644 --- a/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.hlsl +++ b/com.unity.visualeffectgraph/Shaders/Common/VFXCommonCompute.hlsl @@ -54,7 +54,12 @@ float3 VFXGetViewWorldPosition() return (float3)0.0f; } -float VFXLinearEyeDepth(float4 posSS) +float VFXLinearEyeDepth(float depth) +{ + return 0.0f; +} + +float VFXLinearEyeDepthOrthographic(float depth) { return 0.0f; } diff --git a/com.unity.visualeffectgraph/Shaders/RenderPipeline/Universal/VFXCommon.hlsl b/com.unity.visualeffectgraph/Shaders/RenderPipeline/Universal/VFXCommon.hlsl index a26bf89fdc0..06e6f1a2300 100644 --- a/com.unity.visualeffectgraph/Shaders/RenderPipeline/Universal/VFXCommon.hlsl +++ b/com.unity.visualeffectgraph/Shaders/RenderPipeline/Universal/VFXCommon.hlsl @@ -105,12 +105,13 @@ float4x4 VFXGetViewToWorldMatrix() float VFXSampleDepth(float4 posSS) { - return LoadSceneDepth(uint2(posSS.xy)); -} + float2 screenUV = GetNormalizedScreenSpaceUV(posSS.xy); -float VFXLinearEyeDepth(float depth) -{ - return LinearEyeDepth(depth, _ZBufferParams); + // In URP, the depth texture is optional and could be 4x4 white texture, Load isn't appropriate in that case. + //float depth = LoadSceneDepth(screenUV * _ScreenParams.xy); + float depth = SampleSceneDepth(screenUV); + + return depth; } void VFXApplyShadowBias(inout float4 posCS, inout float3 posWS, float3 normalWS) diff --git a/com.unity.visualeffectgraph/Shaders/VFXCommonOutput.hlsl b/com.unity.visualeffectgraph/Shaders/VFXCommonOutput.hlsl index d86cc4c88c6..ebf48497721 100644 --- a/com.unity.visualeffectgraph/Shaders/VFXCommonOutput.hlsl +++ b/com.unity.visualeffectgraph/Shaders/VFXCommonOutput.hlsl @@ -68,12 +68,36 @@ float4 VFXGetParticleColor(VFX_VARYING_PS_INPUTS i) return color; } +float VFXLinearEyeDepth(float depth) +{ + return LinearEyeDepth(depth, _ZBufferParams); +} + +float VFXLinearEyeDepthOrthographic(float depth) +{ +#if UNITY_REVERSED_Z + return float(_ProjectionParams.z - (_ProjectionParams.z - _ProjectionParams.y) * depth); +#else + return float(_ProjectionParams.y + (_ProjectionParams.z - _ProjectionParams.y) * depth); +#endif +} + float VFXGetSoftParticleFade(VFX_VARYING_PS_INPUTS i) { float fade = 1.0f; #if USE_SOFT_PARTICLE && defined(VFX_VARYING_INVSOFTPARTICLEFADEDISTANCE) - float sceneZ = VFXLinearEyeDepth(VFXSampleDepth(i.VFX_VARYING_POSCS)); - fade = saturate(i.VFX_VARYING_INVSOFTPARTICLEFADEDISTANCE * (sceneZ - i.VFX_VARYING_POSCS.w)); + float sceneZ, selfZ; + if(IsPerspectiveProjection()) + { + sceneZ = VFXLinearEyeDepth(VFXSampleDepth(i.VFX_VARYING_POSCS)); + selfZ = i.VFX_VARYING_POSCS.w; + } + else + { + sceneZ = VFXLinearEyeDepthOrthographic(VFXSampleDepth(i.VFX_VARYING_POSCS)); + selfZ = VFXLinearEyeDepthOrthographic(i.VFX_VARYING_POSCS.z); + } + fade = saturate(i.VFX_VARYING_INVSOFTPARTICLEFADEDISTANCE * (sceneZ - selfZ)); fade = fade * fade * (3.0 - (2.0 * fade)); // Smoothsteping the fade #endif return fade;