• Advertisement
Sign in to follow this  

Reconstruct position from depth

This topic is 1432 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to reconstruct position from depth in World Space (WS), but my code produce incorrect results.

 

So what I do:

 

1) Create depth map:

    for each vertex do:

   

viewPos = POSITION_WS * matrixView;

Depth = viewPos.z / farClipPlane;

 

2) Get corners of camera view frustrum in WS (cornerRayWS)

3) Use far plane corners and reconstruct depth for (x, y) -> <0,1>

 

cornerRayWS_interp = lerp(lerp(cornerRayWS[0], cornerRayWS[1], x),

                          lerp(cornerRayWS[2], cornerRayWS[3], x),

                          y);

 

reconstructed_posWS = camera_pos_ws + Depth * cornerRayWS_interp;

 

But my results are incorrect. You can see input calc values for one camera position and view matrices in atached screen. From that I reconstruct position.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement