How to convert Scene depth to distance from camera?

I’m trying to make a custom volumetric fog shader, and right now I’m encountering some issues sampling 3D noise. The noise itself works perfectly, but the issue is I need to convert the scene depth into actual distance, as the scene depth is actually the distance from the camera to the pixel’s view plane.

I’ve been working with HLSL, but I made this attempt using shader graph for convenience. It almost works, but the Noise drifts when moving around the scene, rather than staying consistent with the surface like it should. Does anyone know what the issue is or how to do this more conveniently? The noise shader is from GitHub - JimmyCushnie/Noisy-Nodes: Adds various noise generation nodes to Unity Shader Graph, including 3D noise nodes.

here is the graph:

I’m closing this because I found a great resource here that perfectly explains how depth textures work and a shader graph solution for what I’m doing! Depth | Cyanilux