Tree Culling

Member
Posts: 509
Joined: 2002.05
Post: #1
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.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
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
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
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.
Quote this message in a reply
Member
Posts: 196
Joined: 2003.10
Post: #4
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #5
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.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
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.
Quote this message in a reply
Member
Posts: 196
Joined: 2003.10
Post: #7
So how about a build of that new motorcycle game? That one looks terrific.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #8
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)

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #9
Check out the redbook... Smile

Global warming is caused by hobos and mooses
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #10
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #11
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #12
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.
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #13
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...
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #14
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...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Help With Procedural Tree Algorithm Nick 1 3,580 Jul 26, 2006 10:56 AM
Last Post: unknown
  Alternate Back face culling Sohta 6 4,529 Aug 6, 2004 06:10 PM
Last Post: Sohta
  tree rendering NYGhost 9 4,044 Jan 9, 2004 02:43 PM
Last Post: NYGhost
  Math problem involved in culling DJBlufire 5 3,190 Feb 4, 2003 06:35 PM
Last Post: NYGhost
  BSP tree compiler ClarustheDogCow 3 3,683 Jul 4, 2002 09:30 AM
Last Post: ClarustheDogCow