How to render scene depth right?

I’m using CaptureComponent2D with Post Process Material and Final Color (LDR) in RGB to get scene depth in A component.

For some reason I can’t get same result as buffer visualization:

213603-scene-depth.png

I’m getting this:

213604-scene-filled.png

No gradient, just one color. I guess something is wrong with material but I have no idea how to add gradient to blue color.

UPDATE

When I modified my material according to @redbox comment I got right result. Here is how my material looks like now:

And here is render target:

213692-new-render-target.png

Where is render target texture from SceneCapture? You need its Alpha to get depth from there.

So pass render target texture to your material as texture parameter in runtime.

Could you add an example? I don’t understand why I need render target.

You said that you use CaptureComponent2D, so I understand that you capturing something with that component and want to get scene depth from it, right?

I want to get same picture as I provided from buffer visualization. Yes, I use CaptureComponent2D.

Well, ok.

Image from buffer visualization is normalized. With original depth data it will be very bright. It’s not right to clamp it. Try to use only Normalize or Divide.

I tried to change Clamp to Normalise but got black output. Also I tried to remove Clamp at all and connected Divide to Larp’s alpha input directly but got result same as Clamp produce.

Thank you, I finally got it working. Could you please copy your comment to answer so I can mark it as correct answer?