Yet another BoundingFrustum-Thread

Started by
3 comments, last by necro1895 11 years, 9 months ago
Hy there,
as you can read i still need some hints with the bounding-topics. Some quick information about the stuff i'm trying to do.
I'm coding a small planetary engine with procedural landscapes. Thats working well so far and so i want to implement view dependent LoD. That means i calculate each turn all patches which i have to render. To allocate the concerned patches i need the information whether the patch is in view frustum (camera view) or not.

My camera class is calculating the bounding frustum each turn via multiplying the view and projection matrix. You can see the matrices on the debug messages from the screenshots. The screenshots are showing three states.
1) - Start phase, the patch have to be rendered - you can see the bounding box of it
2) - I'm moving on the x-Axis but the patch is still in view
3) - I'm moving further on the x-Axis and the patch disappears from the view, but the BoundingFrustum doesnt detect that fact. You can see this on the bottom of the debug information (third-last line)

This behaviour is odd and i dont know why. There are less examples for the bounding-topic - especially for BoundingFrustum. So i have to ask you to share your experiences with that topic.

Please ask if you need more information or anything else.

Up vector is y-Axis, and i have a mouseLook camera which is calculating the view matrix from quaternions.

+120708153900.png+120708153904.png+120708153916.png
Advertisement
Ok, i found out, that the Frustum is working correctly if i check the containment against a single point. So I'll have to do some researches about the BoundingBoxes. How annoying.. -.-
One thing I like to do when debugging frustum culling issues is to add a "freeze culling mode", where the bounding frustum gets locked in place but you can still move the camera around. Then if you draw the frustum and the bounding boxes/spheres, you can see whether or not they actually intersect. Drawing a frustum is pretty easy: just take 8 points that start on the unit cube (-1 <= x <= 1, -1 <= y <= 1, 0 <= z <= 1) and transform them by the inverse of your view * projection matrix, and you'll have the 8 points of the frustum.
Nice formula, i will try that. I will compare the result of this with the computed frustum of xna -> frustum.getCorners() should deliver the same values.
[color=#000000][font=arial, sans-serif]

After playing around with some matrices i didnt find any matrix which fits the bounding frustum cube. The first one is the inverted matrix of view * projection. The second one was computed by xna via boundingFrustum.Matrix. [/font]

[color=#000000][font=arial, sans-serif]

The screenshot shows the frustum on the start position. I freezed the frustum for strafing rightwards.[/font]

[color=#000000][font=arial, sans-serif]

Whats wrong with these matrices? There are in no cases a trapezium. [/font]

[color=#000000][font=arial, sans-serif]

Btw, i got the same matrix without inverting the view*projection matrix like the frustum matrix. There is something really odd with that. [/font]

[color=#000000][font=arial, sans-serif]

I'm using this[/font]
[color=#000000][font=arial, sans-serif]


cubeFrustum.Initialize(Matrix.Invert(camera.matrixView * camera.matrixProjection));
[/font]
[color=#000000][font=arial, sans-serif]

and this[/font]
[color=#000000][font=arial, sans-serif]


cubeFrustum.Initialize(camera.boundingFrustum.Matrix);
[/font]
[color=#000000][font=arial, sans-serif]

and they are calling these function:[/font]
[color=#000000][font=arial, sans-serif]


public static Vector3[] CreateCube()
{
Vector3[] cube = new Vector3[8];
int idx = 0;
cube[idx++] = new Vector3(-1, 1, 1);
cube[idx++] = new Vector3(1, 1, 1);
cube[idx++] = new Vector3(1, -1, 1);
cube[idx++] = new Vector3(-1, -1, 1);
cube[idx++] = new Vector3(-1, 1, -1);
cube[idx++] = new Vector3(1, 1, -1);
cube[idx++] = new Vector3(1, -1, -1);
cube[idx++] = new Vector3(-1, -1, -1);
return cube;
}
public static Vector3[] CreateCube(Matrix _transform)
{
Vector3[] cube = EngineHelper.CreateCube();
for (int idx = 0; idx < cube.Length; idx++)
{
cube[idx] = Vector3.Transform(cube[idx], _transform);
}
return cube;
}
[/font]
[color=#000000][font=arial, sans-serif]

It works for[/font]
[color=#000000][font=arial, sans-serif]


cubeFrustum.InitializeFromVertices(camera.boundingFrustum.GetCorners());
So i just dont understand, why its not the same as the formula above.[/font]
[color=#000000][font=arial, sans-serif]

+120710195143.png+120710195120.png[/font]

This topic is closed to new replies.

Advertisement