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 @@ -144,11 +144,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 @@ -142,6 +142,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed ShaderGraph materials to select render queue in the same way as handwritten shader materials by default, but allows for a user override for custom behavior. [case 1335795]
- Fixed sceneview debug mode rendering (case 1211436).
- URP Global Settings can now be unassigned in the Graphics tab (case 1343570).
- VFX: Fixed soft particles when HDR or Opaque texture isn't enabled
- VFX: Fixed OpenGL soft particles fallback when depth texture isn't available

### Changed
- Change Asset/Create/Shader/Universal Render Pipeline/Lit Shader Graph to Asset/Create/Shader Graph/URP/Lit Shader Graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ float3 GetWorldStereoOffset()

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
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix incorrect buffer type for strips
- Enabled an optimization for motion vectors, storing projected positions for vertices instead of the transform matrix
- VFX Graph operators keep the same width when expanded or collpased so that the button does not change position
- Fix Soft Particle depth computation when using an orthographic camera [Case 1309961](https://issuetracker.unity3d.com/product/unity/issues/guid/1309961)

## [11.0.0] - 2020-10-21
### 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
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