Appending mesh to existing - best method

Software: Away3D 4.x

seanClusta, Jr. Member
Posted: 24 March 2014 10:08 AM   Total Posts: 38

I’m hoping to create a scene whereby single meshes can be created at any point in time and added to the scene until there are several hundred, or even several thousand, 3D objects in the scene.

I can get good performance (frame-rates) if I generate the individual meshes before-hand, and add them to a single mesh using the Merge object (and I’m getting much better creation time performance if I use the .applyToMeshes method and add them all in a single call using a vector of the stored meshes)

The problem is this doesn’t meet my use-case.

Ideally I would like to add meshes to the existing scene at random points in time (rather than all at once) without it massively slowing performance due to hundreds of draw calls, and without the execution time of re-uploading a massive vertexBuffer each time the new mesh is merged (which is what seems to happen if I merge a new object to the existing mesh which already contains many thousands of vertices - it may hang for several seconds and I’m assuming this is as the new vertexBuffer is re-uploading to the GPU?)

My question is: is there any way to simply append a mesh/set of geometry to an existing vertexBuffer rather than re-upping the entire buffer (which could be huge by now) ?

If not, could anyone recommend an optimal way of adding several thousand objects / sets of geometry to a scene incrementally without a) having a new vertexBuffer / draw call for each object which will affect frame-rate performance due to the high number of calls & b) having to re-upload the merged mesh / vertexBuffer each time a new object is added/merged ?

Thanks

   

Avatar
Fabrice Closier, Administrator
Posted: 24 March 2014 11:33 AM   Total Posts: 1265   [ # 1 ]

What you want is the holly grail: Add loads of models and expect all is added and rendered fast.

Considering a massive buffer representing many meshes, reuploading the merged buffers isn’t really where the cost is when you insert a new mesh data in there. Merge does cost you exec time because it’s not ‘just’ doing the merging. It validates the data by looking at buffers having space in them, looking at shared materials, potentially create new buffers or remove some and finally inserts the data where possible.
If you replace this logic by a dumb one, you could save an enormous exec time. Think here for instance of building pre-filled buffers, and insert your geometry data into a “free slot”. This requires well thought and prepared geometrical elements.

Depending on what you want to do, you might need consider spacial partitioning technics as well, build a series regions/nodes that are updated only when required. You might even consider another data structure than Away’s structure to manage the buffers.

   

seanClusta, Jr. Member
Posted: 24 March 2014 12:06 PM   Total Posts: 38   [ # 2 ]

Cheers Fabrice, and yeah I thought as much (ticking all them boxes was too good to be true and there would have to be a tradeoff somewhere!)

I’m assuming that because all individual object geometry data has been merged there would be no way of me cheating and ‘turning on the visibility’ of individual objects at points in time when they’re added (i.e. uploading all at start and triggering visibility when needed)? My limited knowledge of the 3D pipeline says no (I’m thinking the objects would need to be associated with individual shaders and these would be lost when merged?)

I’ll look into the spatial partitioning techniques you mentioned. I have played with raw Stage3D and AGAL but was hoping to leverage the tools available through a high-level API such as Away3D rather than re-invintenting the wheel.

Thanks for the advice

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X