Im almost sure that the corners position math is correct, I just dont know if I'm creating the planes in a way that the planes normal face inward...The objects in my scene are being incorrectly culled so something is wrong..,
I can help you by giving you my code for computing only the points of the far plane, though it's the same for the near plane, just use the near plane distance imo.
// This is how half frustum width/ height is computed
// Update (call after new camera matrices have been computed)
// The farPlane,fieldOfView,halfFrustumWidth/height are actually scalars (but the same value is just copied to every component of the vector)
void Update(FXMVECTOR cameraPosition,FXMVECTOR cameraDirectionNormalized,
FXMVECTOR farPlane,CXMVECTOR fieldOfView,
CXMVECTOR halfFrustumWidth,CXMVECTOR halfFrustumHeight,CXMVECTOR cameraUp)
{
// Frustum center
XMVECTOR frustumCenter=XMVectorMultiply(cameraDirectionNormalized,farPlane);
//frustumCenter=XMVectorAdd(frustumCenter,cameraPosition);
// Store to XMFLOAT4s
XMStoreFloat4(&m_cornerTopLeft,cornerTopLeft);
XMStoreFloat4(&m_cornerTopRight,cornerTopRight);
XMStoreFloat4(&m_cornerBottomLeft,cornerBottomLeft);
XMStoreFloat4(&m_cornerBottomRight,cornerBottomRight);
}
Why do you compute the viewing frustrum in world space ?
I think it would be better to compute it in view space : you 'd have to rebuild it only when projection matrix is changed (quite rarely commonly) instead of at each camera change.
Why do you compute the viewing frustrum in world space ?
It's often convenient to perform frustum culling in world space. Building the frustum is cheap and doing it once per frame should cause no problems with performance.
Conversely, if you build the frustum in view space, you may end up having to transform bounding volumes or other geometry into the local space of the camera for culling purposes. As such, building the frustum in view space could actually end up being more costly than building it in world space, not less.