Jump to content

  • Log In with Google      Sign In   
  • Create Account


Calculating Far Frustum Corners in Pixel Shader


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
2 replies to this topic

#1 TiagoCosta   Crossbones+   -  Reputation: 1863

Like
0Likes
Like

Posted 04 May 2012 - 04:09 PM

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 MJP's article:

So I draw a fullscreen quad with the following vertices:

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)
};

And the vertex shader looks like this:

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;
}

However positionVS gets values like: (-0.736, -0.414, 1.0); which is far from a far frustum corner position in view space...
Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development

Sponsor:

#2 jameszhao00   Members   -  Reputation: 267

Like
1Likes
Like

Posted 04 May 2012 - 04:38 PM

(-1, -1, 1), ... are in NDC space.

NDC -> VS

float3 ndc = //....
float4 hcs = float4(ndc, 1) * invProj
float3 vs = hcs.xyz / hcs.w

#3 TiagoCosta   Crossbones+   -  Reputation: 1863

Like
0Likes
Like

Posted 04 May 2012 - 05:06 PM

Thanks I totally forgot to do the w-divide.
Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development




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.



PARTNERS