Hi there!
So i have been trying to understand how does the depth renderer works in babylonjs with https://doc.babylonjs.com/divingDeeper/materials/advanced/depthValuesDepthRenderer and if i understand correctly the depth map stores in each pixel the depth of the scene at that point relative to the camera.
But there must be something i’m missing because rotating the camera without changing its world position shouldn’t change the depth because the distance between the camera and the mesh doesn’t change.
But when i try it : https://www.babylonjs-playground.com/#1PHYB0#93 it’s like when i turn the camera, the sphere is further away or something but it doesn’t move and i don’t get it if someone could explain it to me it would help me a great deal.
Welcome aboard!
It’s not the distance in the world space which is recorded in the depth map, it is the z coordinate of each pixel in screen space (note it is a “depth buffer”, not a “distance buffer”). You can visualize this as being the distance between the screen plane and the object: if you rotate the camera, the object will move closer or further away from the screen plane.
Oh that’s it ! That explains the problem. Thank you very much Just need a bit of geometry and i will have the distance then.