Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ruudje

Frustum Culling

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, another question: Is it possible to do this culling technique (skip rendering of what can't be seen by the camera) per object? I've never even done normal culling before, so maybe this is a stupid question, but I'm planning of having a "large" world-object in 3ds, and don't want to loose my entire fps-count [edited by - Ruudje on September 3, 2003 5:31:08 PM]

Share this post


Link to post
Share on other sites
Advertisement
Thats what i am doing. Also im not using Octrees, since my scenes are not really that huge and frustum culling is more than enough since i have below 100 objects in a scene.

Frustum culling by per object is great because a large number of polygons can be excluded if they are not in the frustum. The method is exactly the same as culling by triangles. Only difference is the bounding sphere/circle/box contains a whole object instead of a triangle.

It should be quite easy to calculate the bounding sphere or box for you objects by using the min/max x/y/z values.

Share this post


Link to post
Share on other sites
It''s not just possible, it''s (more or less, depending on numbers) required. Some form of culling will be needed or you''ll kill your card by throwing geometry at it that can''t be seen. Large worlds often use hierarchical structures (e.g. BSP, octrees, quadtrees etc.) to speed up culling even more. For a large world in 3DS which will essentially be a polygon soup, you might consider an octree, or some sort of AABB tree.

Share this post


Link to post
Share on other sites
I strongly suggest storing polygons in nodes of an octree. Frustum culling is not practicable per polygon in my opinion, as the position of each polygon is checked.

Share this post


Link to post
Share on other sites
As mentioned before, frustum culling is done per-object. Use a bounding-sphere/box to check if the object lies within your view frustum. If you have a large object, like a terrain or the world/level (BSP, etc.) you can use Qaud- or Octree. With this technique you divide your vertex data into small groups and only render those groups (they are defined by a bounding-box) that lie within your view.

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.

Share this post


Link to post
Share on other sites
Check out www.gametutorials.com - OpenGL Tutorials - Page 5
They have a good tutorial about Octrees, there is a .html file with the Download that describes the technique. Quadtree is actually the same with the only difference that 4 Boxes instead of 8 are used (you will know what I mean when you read that tutorial). Quadtree is more often used in connection with terrains and Octree with in-house worlds.

EDIT: Sorry, Page 5 not 4

[edited by - ZMaster on September 3, 2003 1:30:51 PM]

Share this post


Link to post
Share on other sites
funny... i just read that stuff :D

anyways, the html did explain the theory, but not how to do it. I havent looked at the code yet (guess the same code would work for cbuilder right? since its .net)

Before posting here I had a different idea, and wonder what you all think of it:

The world-file would be read in and all vertices would be stored. Next up I would check (somehow) whether or not the vertex I am about to draw is in front or behind the camera. If its in front of it, draw it using the glVertex3f(...), else just skip it. That would basically be tutorial # 10, but everything behind the camera would get cut off... I''m not sure this is gonna work though, since I havent tried it yet, nor know how I''m gonna load 3ds-models and store their data...

Share this post


Link to post
Share on other sites
check out the octree tutorials at gametutorials.com that is where I learned how to make octrees (using the octree class). Once again, I repeat, group vertices (preferably polygons) in an octree and check the octree section (i.e. node) to see if it is in the frustum.

Share this post


Link to post
Share on other sites
Ruudje, I know what you mean and I already tried that. The Problem is, that if a one vertex of a triangle is behind the camera and the others lie within the view, the triangle wouldn''t draw because it would need 3 to draw correctly (sometimes it draws but gives a wiered shape since the triangle takes a vertex that doesn''t actually belong to it).
Maybe you should do it per triangle, like this:

Check_if_one_of_those_vertices_is_in_frustum();
//draw the triangle
glVertex3f();
glVertex3f();
glVertex3f();

But if you do it like this you can''t get the performance advantage of for example GL_TRIANGLE_STRIP if you don''t use some intelligent re-ordering system of your vertices. You see, it''s pretty complicated and If I were you, I would do it with Octrees/Quadtrees.

PS.: The tutorial source code has a detailed explanation in form of comments. Just go through it - it sets the theory of the .html tutorial into code.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!