I have a shader that works fine in perspective view, but if I set my camera to orthographic, it no longer works. This is because my Graph uses the Scene Depth node, which, I believe, assumes you’re using a perspective camera and thus doesn’t give me the correct depth buffer value when my camera is set to orthographic.
TLDR How do I get the depth buffer of an orthographic camera in Shader Graph?
(Documentation of the Scene Depth node: Scene Depth Node | Shader Graph | 7.3.1)
Hmmm ok, so I took a look at that article and it helped (thanks!), but the effect isn’t quite perfect yet. I’ll try to give some more information on what I’m trying to accomplish and what isn’t working.
I’m making a shader that renders the intersection between a sphere and other geometry. I took the Graph from this thread: ( Highlight (Intersection) Shader ), which works fine in Perspective camera mode.
The (otherwise invisible) sphere leaves a red mark wherever it intersects with geometry
But, I want to use an orthographic camera, which doesn’t render the sphere at all because of the Scene Depth node. I took the Graph from the thread I mentioned and tried to replace the Scene Depth node with what I read in the article from the reply above. The sphere now renders in orthographic mode (yay!), but when the object is too far from the camera view’s center, it gets partially cut off. (awww…) Note that I’m not “zooming out” the camera; if the camera moves to the left or right for instance, the object gradually gets cut off more and more as it gets closer to the edge of the screen.

First image is when the camera is centered above the red circle. Second image is after the camera moves to the left
I’m not sure why it’s getting cut off. (I’m new to shaders and Shader Graph and am just throwing some nodes together and trying to learn how everything works as I go along.) Below is the Graph that I have right now. The main thing I’m unsure about, is the Lerp node at the far right of the “Orthographic Depth” group, as I didn’t fully understand the article when it said “we also likely need to Lerp [the result] with the near and far clip planes to have the depth in terms of View space units”
Sorry for the wall of text! But if anyone has tips on how to possibly fix this, I would much appreciate it! 
To whoever may be interested: I ended up using a very different, far simpler shader that does exactly what I need it to. (See image below). Never did solve the problem with the original shader (any tips would still be appreciated!
), but if anyone is looking to get a similar effect, here’s where I got the shader: Reddit - Dive into anything
