Frustum Culling

Started by
28 comments, last by Ruudje 20 years, 7 months ago
Yeah I was looking for that triagle_list stuff, but NeHe doesnt cover it does he? I remember that somewhat from my d3d7 time... but never really did much with it. (I was 2D all the way man! :D )

tnx for all the advise
Advertisement
quote:Original post by ZMaster
BTW: Is anyone familiar with the problem, that objects that lie within the view are culled though they shouldn be? If I fake the position of the object (for example give a y - 10 value to my CheckCubeInFrustum() function) it''s not culled anymore.


Using bouding boxes, sometimes the corners of your box are outside the frustum (each side of the frustum for example)so it''s culled but it shouldn''t.

\ /
+-\--/---+
| \/ |
| |
| |
| |
+--------+

The tutorial mentions this problem but dont solve it. I solved it, but I use my own function for culling.
 \    /+-\--/---+|  \/    ||        ||        ||        |+--------+


Fixed your ASCII art
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Great !!!
Ohh, I see. Could you tell me how you solved the problem? Would be interesting... TIA
You can generalise Sutherland Hodgeman clipping to work with a 3d frustum instead of a 2D plane to solve this problem Its pretty easy to implement too.
I used some functions I wrote to get the point coordinates in the camera space. From this I can know if a point is to the left or to the right of the camera. My computation was something like "if some corners of the bounding box are to the left and some others are to the rigth AND are in front of the camera, then display it".

I dont remember exactly how the tutorial works, but I think it''s something like using planes equation ax+by+cz+d with the 6 frustum planes. With this equation < 0 or > 0 (depends of the plane''s definition) you can know if a point is from one side or the other of the plane.
Depending of each plane, you can know if a point is to the left or to the rigth of the plane. Then for your bounding box you should save the number of point being to the left and to the rigth. If all the points are not to the left or to the right, that means that the bounding box crosses the frustum.

You should do the same for up and down planes
Ok, I see.

But what I actually thought about is, that it can''t be this kind of problem since bouding spheres have the same strange behaviour. I double-checked my frustum culling class and came to the result that it can''t be some mistake in there, because I also tried an exact copy of the gametutorials.com class and had the same problems. Could it be something in conjunction with the matrices? Is there something important to take care about when dealing with gluLookAt, in this case?
What test do you perform with bouding spheres ?
It''s done like this:

bool ViewFrustum::SphereInFrustum(float x, float y, float z, float radius){ for(int i=0; i < 6; i++) {  if(myFrustum[i][A] * x + myFrustum[i][B] * y + myFrustum[i][C] * z + myFrustum[i][D] <= -radius) { return false; } } return true;}


I check for every of the 6 planes of the frustum if point + radius lies behind one of them (using the plane equation)

This topic is closed to new replies.

Advertisement