How to get world position from depth on orthographic camera?

This goes well on perspective camera.

But get no effect on orthographic camera.

Is there any different?

I get the right effect like this.

So the depthMap for perspective camera and orthographic camera is different?

Yes, the projection matrix is different between perspective and orthographic mode, so the depth values are different too. In the orthographic case, the z values in clip/NDC space are in the [-1,+1] range, so your fix is the right one.

2 Likes

And the range is [0,+1] in WebGPUEngine ?

Yes. You can refer to this page for the maths. It’s for shadow generation, but the orthographic/perspective matrices are the same for cameras:

2 Likes

Thank you so much!