Framerate down to 5 with ~50k polys??

Software: Away3D 4.x

Avatar
vonWolfehaus, Newbie
Posted: 05 January 2012 11:18 PM   Total Posts: 14

I thought Flash 11 could handle millions of polys, but with only 50,000 it slowed to a complete crawl!

There are no lights, there’s one texture used for all the models (duplicated OBJ models), and antialiasing x2 on, nothing else. What’s going on?

   

Somokon, Member
Posted: 06 January 2012 12:00 AM   Total Posts: 75   [ # 1 ]

If all your models are separate Mesh objects, it will be slow because the engine must make a lot of expensive draw calls to the GPU.

You should take a look at the tools.Merge class which can combine separate geometries into a single Mesh class.

   

Avatar
vonWolfehaus, Newbie
Posted: 06 January 2012 12:08 AM   Total Posts: 14   [ # 2 ]

I heard about that and I did try that, but merging meshes actually INCREASED polycount and killed the framerate even more.

I have a “parent” mesh with no geo and 2 meshes added as children. Merging the two children into the parent causes an increase in polycount.

I can actually merge all the polys into one mesh since it’s a static game board, but these early results are not promising.

   

Somokon, Member
Posted: 06 January 2012 12:30 AM   Total Posts: 75   [ # 3 ]

Hmm that musn’t be your problem then.  I’ve been able to have 1+ million polys at 60 fps so it is definitely possible.

What are your system specs?  Are you sure that flash is not falling back to software mode?  AwayStats should say ‘DirectX’ or ‘OpenGL’, and not ‘Software’, underneath the poly count.

   

Avatar
vonWolfehaus, Newbie
Posted: 06 January 2012 12:39 AM   Total Posts: 14   [ # 4 ]

I should mention that I have about 3300 “parent” meshes. So maybe that is the problem, but merging sure wasn’t a solution, unless I did it wrong somehow.

I tried merging ALL meshes into a single ObjectContainer3D but it dropped the performance further.

Edit: Should mention I use Mesh.clone() for each new object, where the mesh is grabbed from AssetLibrary.getAsset(), so it should be using a single reference to geo and material.

It’s running DirectX9. I have an Intel Core2 Quad, an nVidia GTX 560 Ti, and 8bg of RAM. I don’t think it’s my hardware.

   

Avatar
Alexander Seifert, Moderator
Posted: 06 January 2012 09:01 AM   Total Posts: 129   [ # 5 ]

I have been out of the code base for a little while now. So don’t take my answer as an official statement wink

But if things haven’t dramatically changed, the 3k+ objects are a very good reason for a bad frame rate. After all, they need to be depth sorted, which is done in software, which is the greatest weakness of Flash so far. ActionScript is really, really slow*.

However, merging EVERYTHING into one single object should definitely speed up that process. If it doesn’t, there may really be more wrong than just the number of objects.

Are your objects interactive (mouse enabled)?
As mouse enabled objects are internally rendered a second time each frame, this could essentially double the draw calls.

Do you have demo online that people can take a look at?

Cheers!
Alex

* a topic worth of its own Wiki.

 Signature 
signature_image

http://www.deltastrike.org

   

Avatar
vonWolfehaus, Newbie
Posted: 06 January 2012 05:34 PM   Total Posts: 14   [ # 6 ]

I’m fully aware of AS3’s shortcoming as a performance machine unfortunately, but I’ve seen Molehill handle much more than I’m throwing at it… just wish it were easier but apparently it’s more of the same :/

Merging all the objects in the scene sounds like a good idea in principle but as I mentioned earlier, it actually doubles the polycount and destroys the framerate some more.

Every object IS mouse-enabled actually, but disabling that didn’t make a difference either. Man, double-rendering sounds terrible… why would they do that?

I’m trying to disable everything and I got the bare minimum working with only render() being called in update and it’s still slow as ever. Cutting down on the number of objects DOES make a huge difference, so maybe it’s the way I’m creating them?

Here’s what I’m looking at: http://coldconstructs.com/random/projectx/
It’s actually around 20 fps in the browser… which is weird. In debug offline it’s around 5fps; release version brings it up to 10-15; release online is around 20fps. So that’s good news, but the issue remains—20fps is crappy performance for the few polys I have displayed.

Creation of each tile is spread across several classes, like this:
Global static class:

library AssetLibrary.getInstance();
library.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
library.load(new URLRequest("../src/assets/hex-top.obj"), new OBJParser(), null"hexTop");
library.load(new URLRequest("../src/assets/hex-side.obj"), new OBJParser(), null"hexSide1");


static private function 
onAssetComplete(event:AssetEvent):void {
 
if (event.asset.assetType == AssetType.MESH{
  
var mesh:Mesh event.asset as Mesh;
  if (
event.asset.assetNamespace == "hexTop"mesh.material allStratMaterials["neutral"][0];
  else if (
event.asset.assetNamespace == "hexSide1"mesh.material allStratMaterials["neutral"][1];
  else 
trace("[Global.onAssetComplete] WARNING: Unknown namespace");
  
library.addAsset(mesh);
  
_hexesLoaded++;
  if (
_hexesLoaded == 2{
   tilesReady 
true;
   if (
map.tilesReady == truemap.refreshTiles();
  
}
 }
}

static public function getTileAssets():Vector.<Mesh{
 
var top:Mesh library.getAsset("obj0""hexTop") as Mesh;
 var 
side1:Mesh library.getAsset("obj0""hexSide1") as Mesh;
 var 
nm:Vector.<Mesh> = new Vector.<Mesh>(2true);
 
nm[0] Mesh(top.clone());
 
nm[1] Mesh(side1.clone());
 return 
nm;

Then in the Hexagon class itself:

public function refresh():void {
 
var m:Vector.<Mesh> = Global.getTileAssets();
 
topFace m[0];
 
sideFace m[1];
 
addChildren(topFacesideFace);
 
 
topFace.scaleX topFace.scaleZ _scale;
 
sideFace.scaleX sideFace.scaleZ _scale;
 
setHeight(_height);
 
topFace.material matStrat[0];
 
sideFace.material matStrat[1];
 
 
//topFace.mouseEnabled = true;
 //topFace.addEventListener(MouseEvent3D.MOUSE_DOWN, onMouseDown);
 //sideFace.mouseEnabled = true;
 //sideFace.addEventListener(MouseEvent3D.MOUSE_DOWN, onMouseDown);

And the materials are assigned in other classes repeatedly, depending on the game state. They just get pulled from some global reference of the same materials.

I have the mouse listeners disabled to show that it didn’t improve performance much, if at all (didn’t notice). Thanks guys for the help already! I’m still getting the hang of things here smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X