# Calculating Far Frustum Corners in Pixel Shader

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

## 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 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...

##### Share on other sites
(-1, -1, 1), ... are in NDC space.

NDC -> VS

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

##### Share on other sites
Thanks I totally forgot to do the w-divide.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632936
• Total Posts
3009312
• ### Who's Online (See full list)

There are no registered users currently online

×