iDevGames Forums
Tree Culling - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Tree Culling (/thread-5991.html)



Tree Culling - Jake - Jan 5, 2005 08:39 PM

I was wondering about how much of a performance gain will I get if I supply normals to all my trees in GL Golf, here is a screenshot

[Image: glgolf1.1.jpg]

Any ideas? Is it worth doing, I am concerned about people on older computers (<500MHZ) because of the old video cards that come with them.


Tree Culling - ThemsAllTook - Jan 5, 2005 08:59 PM

You don't supply normals for your trees!? No wonder they've always looked so weird!

Normals have nothing to do with culling. Culling is determined by winding order. Provided you have GL_CULL_FACE enabled, and draw all of your polygons in counter-clockwise order, the appropriate things will get culled. But you should definitely provide normals for your trees in either case; it should give you a nice visual improvement.

- Alex Diener


Tree Culling - TomorrowPlusX - Jan 6, 2005 07:46 AM

I wouldn't worry about the performance hit either of sending normals along with vertices. I've *never* seen a performance hit, even with terrain with something like 15k triangles. So long as you're not drawing in immediate mode ( e.g., display lists, vbos ) it's not a big deal. And you'll get lighting.


Tree Culling - blobbo - Jan 6, 2005 09:10 AM

I've always thought it would be a huge improvement if, when you played glgolf, you were part of the larger course... i.e. in the flyby it would show the other holes laid out in a "golf course" manner. I've always thought it was a bit weird that you're playing this hole in the middle of this huge green world, and I thought it was because you didn't have enough trees, but I think it's the fact that there's no "location." Also, have you thought about adding different varieties of trees? Different shades of grass? Also, your water seems to lack "depth." It would be neat if it shaded deeper blue based on the depth of the terrain...

Don't get me wrong - I think glGolf is awesome, a terrific game. Just some ideas.


Tree Culling - Jake - Jan 6, 2005 05:35 PM

ThemsAllTook Wrote:You don't supply normals for your trees!? No wonder they've always looked so weird!

Normals have nothing to do with culling. Culling is determined by winding order. Provided you have GL_CULL_FACE enabled, and draw all of your polygons in counter-clockwise order, the appropriate things will get culled. But you should definitely provide normals for your trees in either case; it should give you a nice visual improvement.

- Alex Diener

I guess I never really had the time back when I was learning about 3D program to try to add normals to the trees, but now from experience I know that will be very easy and will do it soon.

WHAT??? Am I really confused on what culling is? I thought you specified what direction a triangle is facing, and then after the translation if it is facing away it gets skipped and isn't drawn. What is this winding thing you are talking about, and is my way right because it works in my motorcycle game and in the terrain for GL Golf.


TomorrowPlusX Wrote:I wouldn't worry about the performance hit either of sending normals along with vertices. I've *never* seen a performance hit, even with terrain with something like 15k triangles. So long as you're not drawing in immediate mode ( e.g., display lists, vbos ) it's not a big deal. And you'll get lighting.

I was saying a performance BOOST, because the video card can skip over half the polygons on the trees, which should reduce the fill per frame alot


Thanks for the suggestions about GL Golf, but it is a side project that is my primary income, I am working on my other games now and only spend a few hours a week on GL Golf.


Tree Culling - TomorrowPlusX - Jan 6, 2005 06:26 PM

Yeah: It's a little counter-intuitive that culling is done by winding and not by normals. but so it goes. As long as your windings are consistent, you can call something like:

Code:
glFrontFace( GL_CCW ); //right handed
glEnable( GL_CULL_FACE );

And about half of your polygons won't be drawn.

Anyway, I was just mentioning the normals because your golf game looks like lighting isn't really happening.


Tree Culling - blobbo - Jan 6, 2005 06:44 PM

So how about a build of that new motorcycle game? That one looks terrific.


Tree Culling - BinarySpike - Jan 6, 2005 06:48 PM

Jake Wrote:WHAT??? Am I really confused on what culling is? I thought you specified what direction a triangle is facing, and then after the translation if it is facing away it gets skipped and isn't drawn. What is this winding thing you are talking about, and is my way right because it works in my motorcycle game and in the terrain for GL Golf.
Um, the winding order is how you specify which object face is the "front" (per face)


Tree Culling - BinarySpike - Jan 6, 2005 06:56 PM

Check out the redbook... Smile


Tree Culling - AnotherJake - Jan 6, 2005 08:07 PM

Jake Wrote:WHAT??? Am I really confused on what culling is? I thought you specified what direction a triangle is facing, and then after the translation if it is facing away it gets skipped and isn't drawn. What is this winding thing you are talking about
Culling is removing polygons from the rendering pipeline that don't need to be rendered, to save time.

Like BinarySpike said, vertex winding (again, see red book) is used by the renderer to determine which face is which, which is commonly used for *back-face* culling in OpenGL. IOW, OpenGL won't waste time trying to render faces that would not normally be seen.

You can (and should) also do *object* culling, where you determine whether or not an entire group of polygons (an object) is even within the viewing frustum. That has nothing to do with whether or not a face is showing, but whether a polygon is even within view. OpenGL does not do that for you, you have to calculate that yourself. Basic frustum culling is not very difficult to do, so look into it if you've never heard of it. Object culling can offer *huge* speed benefits if you never knew you were suppose do it. Wink

Normals are normalized vectors (IOW, scaled to be between 0 and 1 in magnitude and centered at the origin) that tell the renderer how to calculate which direction is "outward" from a vertex or polygon. It's used for determining things like light shading on an object for specular highlights and stuff.


Tree Culling - Jake - Jan 6, 2005 09:12 PM

AnotherJake Wrote:You can (and should) also do *object* culling, where you determine whether or not an entire group of polygons (an object) is even within the viewing frustum. That has nothing to do with whether or not a face is showing, but whether a polygon is even within view. OpenGL does not do that for you, you have to calculate that yourself. Basic frustum culling is not very difficult to do, so look into it if you've never heard of it. Object culling can offer *huge* speed benefits if you never knew you were suppose do it. Wink

Normals are normalized vectors (IOW, scaled to be between 0 and 1 in magnitude and centered at the origin) that tell the renderer how to calculate which direction is "outward" from a vertex or polygon. It's used for determining things like light shading on an object for specular highlights and stuff.

I do my own object culling, it renders only a 90 degree slice of the trees. I need to learn open gl sometime instead of just reading a few NeHe tutorials and coding Huh

How come when I use just normals for my terrain surface only the ones pointing towards the camera are rendered, is this a coincidence? I used a few cull commands in Open GL.


Tree Culling - Jake - Jan 6, 2005 09:17 PM

blobbo Wrote:So how about a build of that new motorcycle game? That one looks terrific.

Shivers is working on a rider model, right now there is a stick figure made of cylinders Smile. I hate showing an unpolished product, but what the hell, after I get a few more buildings and a few mile of road I will, ask me again in two weeks, I have to have something to show for my graduation project then.


Tree Culling - AnotherJake - Jan 6, 2005 09:48 PM

Jake Wrote:I do my own object culling, it renders only a 90 degree slice of the trees.
That's gotta be way better than nothing. Frustum culling would narrow that down, but judging by the screenshot you have, maybe not much. I'm sure somebody around here has a good link or two. I wish I could remember where I learned it from originally.

Jake Wrote:How come when I use just normals for my terrain surface only the ones pointing towards the camera are rendered, is this a coincidence?
Most certainly not coincidence, but I don't understand your question enough to divine a response, although it seems like I've seen that before somewhere...


Tree Culling - arekkusu - Jan 7, 2005 02:44 AM

TomorrowPlusX Wrote:Yeah: It's a little counter-intuitive that culling is done by winding and not by normals. but so it goes.
Of course it has to be that way, because you are free to perturb your normals however you like: face normals, averaged face normals, bumped normals...