I was making some experiments with Sandy3d and Papervision3d and I realized some tips to increase the performance.
Firstly, with Sandy3d 3.0, when you create a BitmapMaterial, the BitmapData that you used to create the Material, is cloned to create the BitmapMaterial.texture.
So, one think you can do is dispose the BitmapData that you used to create the Material after instantiating it and also, if you want to update your BitmapData use the BitmapMaterial.texture directly.
Something like this:
[code lang="actionscript"]
var bmpData:BitmapData = new BitmapData(100, 100, true, 0x00000000);
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);
bmpData.dispose();
bmpMaterial.texture.fillRect(new Rectangle(10,10,30,30), 0xffff0000);
[/code]
This will not work with Papervision3d because it uses the same BitmapData instance (in my opinion, smarter).
Now for both, Sandy3d and Papervision3d.
As you make changes on your BitmapData, it’s updated on every poligon.
So, use the BitmapData.lock() and BitmapData.unlock() when you are redrawing your BitmapData texture.
[code lang="actionscript"]
var bmpData:BitmapData = new BitmapData(100, 100, false, 0x00000000);
var bmpMaterial:BitmapMaterial = new BitmapMaterial(bmpData);
redrawBitmap();
...
function redrawBitmap(){
bmpData.lock();
bmpData.fillRect(bmpData.rect, 0x00000000);
bmpData.fillRect(new Rectangle(10,10,30,30), 0xffff0000);
var blurFilter:BlurFilter = new BlurFilter(16, 16, 3);
bmpData.applyFilter(bmpData, bmpData.rect, new Point(0,0), blurFilter);
bmpData.unlock();
}
[/code]
Vote