Depthpass Texture mapped to Custom Mesh Through Screen Space

https://www.babylonjs-playground.com/#CX5VR3#1

So as far as I can tell the depth map is working… ish… in this scene. I figured at some point the block should be gray not solid black though.

The top half of the scene is rendering the standard camera, the bottom is rendering the depth pass.

I am able to get the depth pass mapped correctly to the cube in screen space, but it seems like it never is anything other then black and white (which is not what I need) and no real gradient to display the depth. I figured the depth pass already scaled the gradient and I do not need to scale it in the shader that I have seen. So I am wondering what I am doing wrong.

Data is stored from that computation: Babylon.js/depth.vertex.fx at master · BabylonJS/Babylon.js · GitHub

but beware as G contains R*R:

vDepthMetric in the vertex fx!!! gotchas!

https://www.babylonjs-playground.com/#CX5VR3#2

Got that working, but now the question comes up why does the depthMap texture not match the what I am seeing witht he vDepthMetric Value?

Ahhhhhh!!! I had to have a camera max and min Z defined for the depth map to work… dumb dumb…

awesome, so there are two ways to pass the depth over then from this!
I think the vDepthMetric is the best way to go, but I did actually learn something from this.

Wonderful :slight_smile: