Custom scene node results in huge performance hit
Posted: Sun May 09, 2010 10:15 pm
I have created a very simple custom scene node based on tutorial 3. It's basically a billboard scene node but it doesn't automatically rotate to face the camera. My code is identical to tutorial 3 except that the geometry is 4 vertices and two triangles to make the billboard, and it has a texture. If the texture uses an alpha channel, then I set the material type to EMT_TRANSPARENT_ALPHA_CHANNEL.
I'm using this scene node to draw 2D sprites in 3D space for a side-scrolling game. The level data is a 2D tile-based map, so I draw each tile using one of these scene nodes. The level I'm working with now is 200 x 200 tiles. That's 40000 tiles total, but there's a lot of empty space in the level so there's on the order of maybe 10000 solid tiles each having a scene node to draw it. At any given time, only a small part of the level is visible, maybe a few hundred tiles, most of the level is off-screen.
The problem is that even though there's not much on screen, my game's performance is hugely affected by the size of the level. Just rendering the 200x200 map, without doing anything else, I'm down to around 60fps. This means that the large number of scene nodes are chewing up all my CPU time, even though 95% of them are off screen.
My question is, is this to be expected, or does it sound like something is wrong? I setup the bounding box like in tutorial 3. Shouldn't the automatic culling keep the off-screen scene nodes from using up too much cpu time? Or is the overhead of 10000 scene nodes too high?
What would be a good approach for this type of game? Should I make each scene node handle something like a 10x10 chunk of the level so there'd only be 400 scene nodes? Should I make the whole level one giant scene node? What's a good trade-off to get reasonable performance?
Thanks a lot for any help!
I'm using this scene node to draw 2D sprites in 3D space for a side-scrolling game. The level data is a 2D tile-based map, so I draw each tile using one of these scene nodes. The level I'm working with now is 200 x 200 tiles. That's 40000 tiles total, but there's a lot of empty space in the level so there's on the order of maybe 10000 solid tiles each having a scene node to draw it. At any given time, only a small part of the level is visible, maybe a few hundred tiles, most of the level is off-screen.
The problem is that even though there's not much on screen, my game's performance is hugely affected by the size of the level. Just rendering the 200x200 map, without doing anything else, I'm down to around 60fps. This means that the large number of scene nodes are chewing up all my CPU time, even though 95% of them are off screen.
My question is, is this to be expected, or does it sound like something is wrong? I setup the bounding box like in tutorial 3. Shouldn't the automatic culling keep the off-screen scene nodes from using up too much cpu time? Or is the overhead of 10000 scene nodes too high?
What would be a good approach for this type of game? Should I make each scene node handle something like a 10x10 chunk of the level so there'd only be 400 scene nodes? Should I make the whole level one giant scene node? What's a good trade-off to get reasonable performance?
Thanks a lot for any help!