Want a Get Depth Texture in HDRP but not working

HI.
I used a translator. Please take into consideration
I want a get RenderTexture From Camera Depth Texture using Commandbuffer.Blit

in 2 ways.

public Material DepthMT;
public RenderTexture RT;

void onEnable()
{
    var data = GetComponent<HDAdditionalCameraData>();
    if (data != null) data.customRender += CustomRender;

    CB = new CommandBuffer();
}

void onDisable()
{
    var data = GetComponent<HDAdditionalCameraData>();
    if (data != null) data.customRender -= CustomRender;

    CB.Release();
}

void CustomRender(ScriptableRenderContext context, HDCamera camera)
{
    if (camera == null || camera.camera == null)
        return;
    
    CB.Blit(BuiltinRenderTextureType.CurrentActive, RT, DepthMT);
    camera.camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, CB);
    context.ExecuteCommandBuffer(CB);
}
public Camera _camera;
public Material DepthMT;
public RenderTexture RT;

void OnEnable()
{
    CommandBuffer CB = new CommandBuffer();
    CB.Blit(BuiltinRenderTextureType.CurrentActive, RT, DepthMT);
    _camera.AddCommandBuffer(CameraEvent.AfterSkybox, CB);
}

Both methods were useless.
Without HDRP, it runs well using OnRenderImage()
With HDRP, it’s not working.
i make Depth Shader use shadergraph.
I uploaded the shader as an image file.

Please Tell me the problem. and show me the relevant documents.
Thanks.

I found a way to solve the problem.

this β†’ https://github.com/alelievr/HDRP-Custom-Passes/blob/master/Assets/CustomPasses/Tests/CameraDepthBake.cs

This example is a Custom pass example, in which the DepthBake example was used in the Tests folder.
Leave the information you find to the person who will have the same problem later.

2 Likes