Hi, David,


David Wilson wrote:
Hi all,

First of all, thanks to the folks who built this library.

I'm building a 3D game engine based on osg::CompositeViewer featuring rather 
larger worlds built using cubes. I've attached an image of what I'm trying to 
create.

I was using ShapeDrawable for the blocks until I read I would get faster 
rendering by building the geometry myself using vertex arrays.

I've implemented something like an octree to create a balanced tree upon level load. The 
nodes of the tree are Group objects and the leaves are Geode objects with multiple 
Geometry objects attached (the faces of each block.) Empty "cells" are culled. 
The minimum cell size for the octree division is 2x2x2 (so a leaf node can contain up to 
8 blocks).

The octree doesn't seem to have given me much of a performance boost in the 
culling department. I am guessing this is because the leaves of the tree 
contain so many geometry objects?

Possibly. An octree design generally works well with a scene graph architecture, so the idea itself is a good one.


I've had a read of the forum and google and have come to the conclusion I 
should do something like the following to improve performance:

1. Group up my geometry objects to perform "batch rendering" - i.e. render more 
than a single face of a single block in one go.

How can I do this? Do I need to create a single geometry object containing 
vertex arrays etc of a whole chunk of block faces?

Yeah, that's a start. You definitely don't want to have one Geometry per face. Ideally, you want to do as much as you can in one primitive set (each primitive set is a draw call, and you want to cut down on draw calls as much as possible).

Obviously, you'll have to balance this goal with your octree design as well.

2. Re-use a single geometry object for block faces. Apparently there is code in 
osgParticle::PrecipitationEffect which does this - although I haven't checked 
it out yet.

3. "Instanced rendering" I'm not sure quite what this is about, but is what 
osg::Impostor does? I just had a look at osgimpostor.exe for the first time while writing 
this, and it seems pretty close to what I want to achieve.

osg::Impostor is an older technique for representing relatively complex objects with a single billboard face. I don't think this will help you.

Instanced rendering is different. It lets you draw multiple instances of the same object very efficiently by using a single copy of the vertex data and a vertex shader to do the positioning for each instance of the object (often, an additional vertex attribute is used to hold the position of each instance). Look at the osgdrawinstanced example for details.

Hope this helps.

--"J"

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to