Getting Depth from RenderTexture?

Hello everyone :wave:,

I am trying to implement an approach similar to this post:

to ray march volume render an effect similar to this:

(the sphere example is ok for simplicity).

I am able to generate two render textures to from two eye cameras, (only showing right camera for simplicity) front is ray marched volume, and back is the obtained render texture on a plane.

I also have this script attached to cameras to populate the render texture every frame:

using UnityEngine;
using Unity.PolySpatial;
using UnityEngine.Rendering;

public class BatchModeUpdateRenderer : MonoBehaviour
{
    Camera m_Camera;
    
    
    void Start()
    {
        m_Camera = GetComponent<Camera>();
    }

    void Update()
    {
#if UNITY_EDITOR
        if (m_Camera)
        {
            RenderAndReadDepth();
        }
#else
        if (Application.isBatchMode && m_Camera)
        {
            RenderAndReadDepth();
        }
#endif
    }
    
    private void RenderAndReadDepth()
    {
        m_Camera.Render();
    }
}

However, I am very lost on how “blit (?)” the RenderTexture’s depth info to a second RenderTexture as explained in the post.

I tried writing a shader/material to pass into Graphics.Blit to copy from, which ended up completely ignoring my camera setup and using the scene camera (very weird, I have no explanation why?).

I would greatly appreciate if someone could explain the process and how this work in relation to the bigger picture.

Thank you very much

A follow up question I have is:

What and where is this depth data? Is there a way to visualize it to make sure it’s correctly being captured in the RenderTexture?