How to create distortion wiht depth test

Hello,

I’m currently adding some distortion effects to my shaders by using the scene color node with a normal map.
But I’m not satisfied with the results since the distortion also takes objects before the mesh into account.
I’m using HDRP. So what’s the best way of getting rid on the artefacts showing by red arrows in the image? I already setup some nodes to get the scene depth.


Bump, anyone knows if it is possible? I saw a lot of different shader graph examples (like water shaders, distortion shaders). All of them have the same kind of problem: The distortion also affect objects in the foreground.

Basically what I need is the HDRP Unlit Transparent Distortion Shader, just as a “Lit” version.

Bump

I have the same problem!