I'm trying to create a distortion trail for a laser beam, but in unity the distortion effect is rendered even if the particles are behind other scene objects.
Tried modifying the distortion shader to work only conditionally if the depth of the particles is less than the depth of the scene, but i'm unable to get any reasonable depth data from the distortion RenderTexture.
float4 frag (v2f i) : SV_Target
float partZ = UNITY_SAMPLE_DEPTH(tex2D(_DistortionTex, i.uv.xy));
float linearPartZ = Linear01Depth(partZ);
... yields this being rendered when clearly this is not a correct depth data.
Are there any workarounds to this problem? Is there a way to get it to work properly with current popcorn version? Is there a solution in development?