Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed terrain hole shadowing [case 1349305]
- Fixed soft shadows shader variants not set to multi_compile_fragment on some shaders (gbuffer pass, speedtree shaders, WavingGrass shader).
- Fixed artifacts in Speed Tree 8 billboard LODs due to SpeedTree LOD smoothing/crossfading [case 1348407]
- 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.2.0] - 2020-10-19

Expand Down
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Remove unexpected expression in spawn context evaluation [Case 1318412](https://issuetracker.unity3d.com/product/unity/issues/guid/1318412/)
- Fix incorrect buffer type for strips
- Compilation issue when normal is used in shadergraph for opacity with unlit output
- Fix Soft Particle depth computation when using an orthographic camera [Case 1309961](https://issuetracker.unity3d.com/product/unity/issues/guid/1309961)

## [10.2.0] - 2020-10-19
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 26 additions & 2 deletions com.unity.visualeffectgraph/Shaders/VFXCommonOutput.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,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;
Expand Down