Original Post
Hi, I have written a function to extract the 6 frustum planes. The code to extract the far plane looks like this: This is the approach from this document (page 3): http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf normalize() normalizes the plane and looks like this: The Problem: If I create a frustum with an eyepoint at the origin (0,0,0), a view vector of (0, 0, 1), the near plane at 100 and the far plane at 6 000 000 (6 million), I get these results: near plane: normal = (0,0,-1) and distance = 100.00002 (which is both correct) far plane: normal = (0,0,1) (correct) and distance = -6013439.5 The distance should be 6000000, shouldnt it? Whats the reason for this huge (!) difference between the expected result and the value I get (more than 13439 difference!). Is something wrong with the algorithm from the paper, or my implemenation or is the reason really just float inaccuracies? I also tried to calculate everything in long double, but I got the same results. Thanks for any answers!
frustumPlanes[5].normal.x = -(viewProjMatrix._14 - viewProjMatrix._13);
frustumPlanes[5].normal.y = -(viewProjMatrix._24 - viewProjMatrix._23);
frustumPlanes[5].normal.z = -(viewProjMatrix._34 - viewProjMatrix._33);
frustumPlanes[5].distance = -(viewProjMatrix._44 - viewProjMatrix._43);
frustumPlanes[5].normalize();
void Plane::normalize() {
float denom = 1.0 / sqrt( normal.x * normal.x +normal.y * normal.y + normal.z * normal.z );
normal.x = normal.x * denom;
normal.y = normal.y * denom;
normal.z = normal.z * denom;
distance = distance * denom;
}