Advertisement

culling vs performance

Started by June 26, 2004 07:13 PM
18 comments, last by Luke Miklos 20 years, 5 months ago
Oh, sorry, with plane you meant the real airplane :). You'll probaly have only one fullscale model on screen (your airplane) so that's not that much of a problem. For the rest of airplanes use some kind of LOD. There is no need to draw a 10k model if it is only 10 pixels on screen.
You should never let your fears become the boundaries of your dreams.
eheh...I dont think your getting my meaning. ill use a different example. lets say Homeworld 2. I like Homeworld 2...everyone likes Homeworld 2. Though being in the Navy as I am I still dont get how ship thousands of years more advanced then us still rely on fighters and battleships when we dont even really do that now. but that is niether here nor there.

my point is its possible to have hundreds of models on the screen at any given time(ships, planets, asteroids, ect.) Thats potentially alot of poly's to draw. So im asking if there is a way to only draw the one side of each ship that you can see. it cuts down from drawing 15 ships with 100 polys to 15 ships and only 50 poly's, or whatever...

get me now?
C_C(Enter witty/insightful/profound remark here...)
Advertisement
Yes, I understand what you want. The point is that most of the ships on screen are small. You don't need to draw full model of ship. You just draw a simplefied model of it. Draw a model with 50 polys instead of one with 500. I wouldn't go about splitting individual ships as there is more troubble than its worth for. Look for some papers on LOD and you'll understaned.
You should never let your fears become the boundaries of your dreams.
Quote: Original post by Cannibal_Codermy point is its possible to have hundreds of models on the screen at any given time(ships, planets, asteroids, ect.) Thats potentially alot of poly's to draw. So im asking if there is a way to only draw the one side of each ship that you can see. it cuts down from drawing 15 ships with 100 polys to 15 ships and only 50 poly's, or whatever...


OpenGL can do that to, it's called backface culling.
But as darkwing said, lod is a pretty good way of saving in on polys.
IT's simple to, basicly make many versions of the same model but with different polycounts, and displa them at various distances.
10000 for upclose shots, 1000 for when they are some distance away from the camera, 50 for objects that are even further away, and 10 for when they are just a dot on the horizon.
Quote: Cannibal_Coder
So im asking if there is a way to only draw the one side of each ship that you can see.


What you are looking for is called 'backface culling' and can be done by the API (e.g: glEnable(GL_CULL_FACE)).

One way to do it is to calculate the dot product between the surface normal and the vector formed by eye → polygon. If it's positive you're looking at the front side of the polygon, otherwise you're looking at it's back [OpenGL takes a different approach...]. Simply don't draw the polygons facing away from you (watch out if you've got reflective surfaces!).

Why not combine backface culling, LOD, occlusion culling and frustrum culling? :)
How do I set my laser printer on stun?
It seems that you are looking for some LOD on Your models
(I sound like the MSWord Paperclip :eek:)
You might want to check out http://cal3d.sourceforge.net
Some really nice code in there. :)

Another thing to consider on Oclusion culling:

For any static objects, you might want to have a look at Octrees, BSP trees or AABB Trees.

All of these are ways of partitioning huge amounts of polygons into more manageable "blocks", that can then be frustrum culled.

The reason for this is that the biggest bottleneck on GFX is normally the AGP, by culling out most of the unneeded polygons before sending it to the GFX Card, you end up saving HUGE.

You can find some Octree Code at www.gametutorials.com
Advertisement
Like McCLaw said, the problem isn't just the time it takes opengl to draw the vertices and fill in the pixels, but also the time it takes to send all that data to the video card over the AGP bus.

I'm sort of shooting from the hip here, so please correct me if I make a mistake. Let's say that you have a 1024x1024 terrain, but you are only looking at a 10x10 chunk of it in the corner (maybe your plane crashed or something). You could just draw the whole 1024x1024 terrain (1,048,576 points, but you need to send more vertices than that because vertices are used multiple times to make polys). OpenGL would figure out that a whole bunch of that is off screen and not try to draw those polys. However, I believe it still needs to tranform every vertex to check. Anyway, you could, through a fairly simple process, cull out all but the stuff that is in your view. What I do is split the terrain into smaller chunks (32x32 maybe) and frustum cull then with a quadtree. There still may be a little overdraw, but let's say your 10x10 view is right on the corner of 4 32x32 chunks, then you'd only have a 64x64 patch to draw. That's only 4,096 points (again, there is some duplication needed to get a polygon, so you'd actually need to send more vertices than that). Of course, that's just a rough example, but I hope you get the idea.

Basically, if you can cut out a significant number of the polys that you need to send and that opengl needs to check to see if they are visible without spending too much CPU time, then you can get huge increases in framerate.
Also, backface-culling / LOD / occlusion on the models is not nearly as important as it is for the database (terrain). Simply put... the terrain should be divided up into a huge quad-tree or oct-tree (depends on how your world is designed) & test your eye-point from each section of the tree first to see if its even in your field of view & second to see what level of detail it should be displayed as. & as you fly forward... you will be constantly paging out the data beneath you as it passes behind you & paging in the data in front of you as it appears on the horizon. High level optimizations like this are MUCH MORE important for good performance.

Another thing to think about... is that you will not be able to give each of these models its own AI & still be able to run smoothly, so maybe cut down on the number of models in your scene.
Wooo...havent been to work in almost 4 days, and can only follow posts while at work since I dont have the net in my barracks quite yet, and I come back to see my post is still under discussion.

Thx everyone for all the insight though. I understand the importance of LOD'ing and the Trees and such but im still a little fuzzy on exactly what face culling does. As far as I understood it it keeps the graphics card from drawing the side of the poly facing toward/away(depending on how its enabled) from the camera. Thats great and all since it cuts my poly count in "half"...kinda. It seems to me though that even if I cull out the backfaces of all the poly's it takes to draw say, a F-4 Phantom, its still drawing the front side of those polygons, whether I can see them or not. Or am I mistaken?

If im not then how do I keep it from drawing the entire side I cant see? One idea that comes to mind is in using the model trees break each model into 8( or more) parts, and only draw the parts that I could see. But that doesnt sound like It would work entirely right.

any thoughts?
C_C(Enter witty/insightful/profound remark here...)
just try out backface culling man, I think thats what you want. And as I said in my AP post up above... there are more important high level optimizations to be had than backface-polygon-culling, which is just a given, you simply enable it.

Whatsoever you do, do it heartily as to the Lord, and not unto men.

This topic is closed to new replies.

Advertisement