LangFox

07-08-2009, 07:22 AM

While there are several ways to reconstruct position from depth, I just read an article which use the following fomular:

// input SV_POSITION as pos2d

New_pos2d = ( (pos2d.xy) * (2/screenres.xy) ) - float2(1,1);

viewSpacePos.x = gbuffer_depth * tan( 90-HORZFOV/2 ) * New_pos2d.x;

ViewSpacePos.y = -gbuffer_depth * tan( 90-VERTFOV/2 ) * New_pos2D.y;

ViewSpacePos.z = gbuffer_depth;

I'm wondering if there is an easy way to get the horizontal fov? Because I usually call gluPerspective to set up the frustum which only use the vertical fov.

// input SV_POSITION as pos2d

New_pos2d = ( (pos2d.xy) * (2/screenres.xy) ) - float2(1,1);

viewSpacePos.x = gbuffer_depth * tan( 90-HORZFOV/2 ) * New_pos2d.x;

ViewSpacePos.y = -gbuffer_depth * tan( 90-VERTFOV/2 ) * New_pos2D.y;

ViewSpacePos.z = gbuffer_depth;

I'm wondering if there is an easy way to get the horizontal fov? Because I usually call gluPerspective to set up the frustum which only use the vertical fov.