Sign in to follow this  

Calculating Far Frustum Corners in Pixel Shader

This topic is 2052 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'm trying to calculate the far frustum corners position in view space in the pixel shader but it's not working...

I'm following[url="http://mynameismjp.wordpress.com/2010/09/05/position-from-depth-3/"] MJP's article[/url]:

So I draw a fullscreen quad with the following vertices:

[CODE]
PVertex vertices[] =
{
PVertex(-1.0f, -1.0f, 1.0f),
PVertex(-1.0f, 1.0f, 1.0f),
PVertex(1.0f, 1.0f, 1.0f),
PVertex(1.0f, -1.0f, 1.0f)
};[/CODE]

And the vertex shader looks like this:

[CODE]
VS_OUT VS(VS_IN vIn)
{
VS_OUT vOut;

vOut.posH = float4(vIn.posL, 1.0f);

#ifdef DIRECTIONAL_LIGHT
vOut.positionVS = mul(float4(vIn.posL, 1.0f), gInvView);
#else
vOut.positionVS = mul(float4(vIn.posL, 1.0f), gWorld).xyz;
#endif

return vOut;
}[/CODE]

However positionVS gets values like: (-0.736, -0.414, 1.0); which is far from a far frustum corner position in view space...

Share this post


Link to post
Share on other sites

This topic is 2052 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this