Welcome aboard!
The depth renderer is rendering linear depth in the depth texture by default but you would need the non linear z value if you use it “as is” as the z NDC coordinate. You can instruct the depth renderer to render non linear z values by passing true
as the second parameter to enableDepthRenderer
:
Note I’m not quite sure what you want to achieve with the vectorToPixel
computation, I’m just returning the world space coordinate.
If you want to use linear z values instead you can compute the world coordinate like this: