Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Reconstruct position from depth

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Martin Perry   Members   

1547
Like
0Likes
Like

Posted 13 February 2014 - 09:00 AM

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.

Attached Thumbnails

  • Clipboard01.png


#2 AverageJoeSSU   Members   

564
Like
1Likes
Like

Posted 17 February 2014 - 02:35 PM

This, this, and this are good for reference. Have you looked at those articles?


------------------------------

redwoodpixel.com





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.