Z buffering in Torque?
by Jason Davis · in Torque Game Engine · 06/23/2006 (8:09 am) · 13 replies
Okay, I can't find any information about this on the forums or resources. With my current mod, I have WAY more triangles showing in my metrics information than what I think they should be. My main player character only weighs in at 1,234 triangles, but when I look straight down on him from above (with just a little bit of the terrain showing under his feet) the metric triangle count is over 2000!!! My question is this: Is TGE performing any Z buffering at all? It seems that the triangle count should be roughly cut in half (compared to the entire model's tri-count) if Z buffering were enabled, since it wouldn't be rendering triangles that are not currently visible. Any help? I'm waiting... Thanks!
- Jason
- Jason
#2
zbuffering has no effect on the triangle count,
or even on triangle rasterization.
it only affects the final visibility of individual pixels belonging to triangles.
also,
for folks who are working at all in 3D graphics,
knowing exactly how buffering works is a really good idea.
it's a particularly elegant algorithm, and a google search will be rewarding i'm sure.
06/23/2006 (11:46 am)
In other words,zbuffering has no effect on the triangle count,
or even on triangle rasterization.
it only affects the final visibility of individual pixels belonging to triangles.
also,
for folks who are working at all in 3D graphics,
knowing exactly how buffering works is a really good idea.
it's a particularly elegant algorithm, and a google search will be rewarding i'm sure.
#3
There could be a number of things affecting your triangle count, including the terrain, any weapons, etc. Anything that that might be in view could be factored into the equation. And, if I remember correctly, any individual mesh painted with two different texture files will be drawn twice. Just a guess, but that might cause some of your triangles to be counted more than once. I haven't tested that theory, though. I'm still learning the particulars of 3D graphics, so I could be majorly wrong on this. :)
By the way, if you ever want to see your scene in wireframe mode, you can type . . .
And you can substitute a 1 where the true is. Using false or 0 here will turn off wireframe mode. Using this command messes up all of your text (until you switch it off), but it helps you see your 'world' at it's most basic.
There's a much more functional set of wireframe options you can use -- but only with a debug-compiled TGE executable. Debug builds are pretty cool, but they're slow as refrigerated honey.
Aaron E.
06/23/2006 (1:44 pm)
Jason,There could be a number of things affecting your triangle count, including the terrain, any weapons, etc. Anything that that might be in view could be factored into the equation. And, if I remember correctly, any individual mesh painted with two different texture files will be drawn twice. Just a guess, but that might cause some of your triangles to be counted more than once. I haven't tested that theory, though. I'm still learning the particulars of 3D graphics, so I could be majorly wrong on this. :)
By the way, if you ever want to see your scene in wireframe mode, you can type . . .
glenableoutline(true);
And you can substitute a 1 where the true is. Using false or 0 here will turn off wireframe mode. Using this command messes up all of your text (until you switch it off), but it helps you see your 'world' at it's most basic.
There's a much more functional set of wireframe options you can use -- but only with a debug-compiled TGE executable. Debug builds are pretty cool, but they're slow as refrigerated honey.
Aaron E.
#4
- Jason
06/24/2006 (8:50 am)
Thanks, guys... Z buffering isn't the main problem then, so thanks for the correction Bruno and Orion. Aaron, you are my undying hero on these forums... I have already given a "Special Thanks" to you (along with a few others from the GG community) for your small but invaluable in-direct contributions to Project Phantom. I will definitely use the glenableoutline() function to optimize some stuff. I didn't even know that function existed.... Thanks again!- Jason
#5
:)
06/24/2006 (11:00 am)
Yep, Torque has lot's of cool gems. Finding them seriously geeks me out. Passing them along to others is almost as fun.:)
#6
06/24/2006 (12:19 pm)
Jason is seems like what your trying to sat is 'frustrum culling", i.e culling any geometry the fails to be inside the view frustrum.
#7
The polys are showing up all right... much more than I want! Torque, as you all know, loops the terrain to go on forever and ever... I don't want this. The "looping" terrain is showing up in the triangles when using glenableoutline. To illustrate, I have one lake in the middle of my terrain. But you can see the lake going on and on through the walls and mountainous terrain with GLEnableOutline!!! Are these "duplicate" lakes that are never used getting redrawn every frame (when they are in the view frustrum)??? I don't want this. Is there a way to disable the terrain duplication? I don't want it!! Help, please!
Thanx,
Jason
06/26/2006 (8:02 am)
Okay, here's what I've found by using GLEnableOutline().The polys are showing up all right... much more than I want! Torque, as you all know, loops the terrain to go on forever and ever... I don't want this. The "looping" terrain is showing up in the triangles when using glenableoutline. To illustrate, I have one lake in the middle of my terrain. But you can see the lake going on and on through the walls and mountainous terrain with GLEnableOutline!!! Are these "duplicate" lakes that are never used getting redrawn every frame (when they are in the view frustrum)??? I don't want this. Is there a way to disable the terrain duplication? I don't want it!! Help, please!
Thanx,
Jason
#8
You can define the water block size, however there is a bug regarding water block size and rendering.
If you made the water block the size of the terrain, then it should not render where occluded by the map terrain, however, as I said there is at least on bug that I know of which relates to map terrain square size and the water block.
06/26/2006 (9:00 am)
When you say the "lake" are you referring to the water block, for the terrain?You can define the water block size, however there is a bug regarding water block size and rendering.
If you made the water block the size of the terrain, then it should not render where occluded by the map terrain, however, as I said there is at least on bug that I know of which relates to map terrain square size and the water block.
#9
So maybe you just need to turn down your view distance. :)
You should also check out the profiler to see what's actually slowing you down, if anything.
06/26/2006 (9:04 am)
The terrain only renders what is visible (or potentially visible). Ie, it does not render things behind you, it does not render things past the view distance. If you portalize your interiors properly it will only render what's needed as indicated by the portals.So maybe you just need to turn down your view distance. :)
You should also check out the profiler to see what's actually slowing you down, if anything.
#10
06/26/2006 (9:12 am)
I'd listen to Ben, I dont really know what I am talking about...did I mention that?
#11
Ben, thanks for the tips. I am not rendering many interiors right now, so it is mainly the exterior environment with terrain, water block, and sky (which really doesn't count, anyway.)
View distance is a definite possibility... I will keep that in mind and fine tune as I go.
Now, the profiler.... how do I use that? I've been working with TGE for a while and believe it or not, I have not heard anything about the profiler.... please explain! :-)
- Jason
06/26/2006 (9:59 am)
Todd, yes I'm talking about the water block.Ben, thanks for the tips. I am not rendering many interiors right now, so it is mainly the exterior environment with terrain, water block, and sky (which really doesn't count, anyway.)
View distance is a definite possibility... I will keep that in mind and fine tune as I go.
Now, the profiler.... how do I use that? I've been working with TGE for a while and believe it or not, I have not heard anything about the profiler.... please explain! :-)
- Jason
#12
06/26/2006 (4:23 pm)
tdn.garagegames.com/wiki/Torque/Profiler has some info. It's a tool for tracking how much time is spent on various sections of code, ie, finding out that you're spending 90% of your time doing vehicle physics or something. :)
#13
06/27/2006 (2:19 pm)
Thanks... I'll do some homework with this!
Torque Owner Bruno Grieco