Framerate problems with panoramic sphere with inverted faces

Software: Away3D 4.x

fjckls, Newbie
Posted: 02 June 2012 09:55 AM   Total Posts: 3

So I have created a panoramic scene with my 360 video being applied as a movie material to the sphere which faces are inverted. I then put the camera inside this sphere.All works except that performance is really bad, on an average machine I get no more than 16 FPS.
Here is the link (wait a while till movie loads, my server is kinda slow and video is approx 14Mb) http://fjofjo.com/panorama/

Also here is the source(FlashDevelop)
http://fjofjo.com/panorama/panorama.zip

How can I increase performance?
Maybe not rendering the parts of the sphere that are not in camera’s view? Any thoughts?

   

Avatar
theMightyAtom, Sr. Member
Posted: 02 June 2012 02:06 PM   Total Posts: 669   [ # 1 ]

Cool stuff smile

What version of Away did you make this with?
Not the current, or any recent build I can see.
I would start by upgrading to Away3D 4.0 beta

Good Luck!

   

Avatar
theMightyAtom, Sr. Member
Posted: 02 June 2012 03:55 PM   Total Posts: 669   [ # 2 ]

I did a little experimenting….
Here’s a version made with the latest Away3D 4.0 engine.
http://videometry.net/panofilm/

I can get it upto 60fps, but only by downsizing the videoTexture.
Interestingly (if a bit of a downer) Stage3D doesn’t seem to have helped much in this scenario.
Yes, the sphere you’re projecting onto can be higher density without affecting performance (this is 36 x 36 segments), but if I run the video at it’s native size (2048 x 1024) it performs about the same as the original Away3D 3.6 version. The video shown is 1024 x 1024.

On the plus side, there’s no optical distortion, i.e. straight lines are straight (sides of buildings, road markings, etc.) when compared to the original version.

Here’s the code

package 
{
 import away3d
.cameras.Camera3D;
 
import away3d.debug.AwayStats;
    
import away3d.containers.View3D;
 
import away3d.entities.Mesh;
 
import away3d.events.MouseEvent3D;
 
import away3d.events.LoaderEvent;
 
import away3d.materials.TextureMaterial;
 
import away3d.primitives.SphereGeometry;
 
import away3d.textures.BitmapTexture;
 
import away3d.textures.Texture2DBase;
 
import away3d.textures.VideoTexture;
 
import flash.display.Sprite;
 
import flash.display3D.textures.Texture;
 
import flash.events.Event;
 
import flash.events.MouseEvent;
 
import away3d.tools.helpers.MeshHelper;
 
 
/**
  * ...
  * @author fjo, with update by theMightyAtom
  */
 
 
[SWF(width="1024"height="768"frameRate="60"backgroundColor="#FFFFFF")]
  
 
public class Main extends Sprite
 {
  
private var _sphere:Mesh;
  private var 
_view:View3D;
  
// Kamera
  
private var _camera:Camera3D;
  private var 
_lastPanAngle:Number;
  private var 
_lastTiltAngle:Number;
  private var 
_lastMouseX:Number;
  private var 
_lastMouseY:Number
  private var 
_bMove:Boolean;
  private var 
_hover:Boolean;
  private var 
_oldX:Number;
  private var 
_oldY:Number;
  
  private var 
_theVideo:Sprite;
  private var 
_vx:Number=0;
  private var 
_vy:Number=0;
  
  public function 
Main():void 
  {
   super
();
   if (
stageinit();
   else 
addEventListener(Event.ADDED_TO_STAGEinit);
  
}
  
  
private function init(e:Event null):void 
  {
   stage
.scaleMode "noScale";
   
stage.align "TL";
   
removeEventListener(Event.ADDED_TO_STAGEinit);
   
stage.quality "LOW";
   
   
   
initApp();
  
}
  
  
private function initApp():void 
  {
 
   _view 
= new View3D();
   
addChild(_view);
   
_camera _view.camera;
   
   
// material - adjust the video dimensions to affect perfomance
   
var mcMat:TextureMaterial = new TextureMaterial(new VideoTexture("video/ladybug.f4v"10241024,true,true),true);
 
//  mcMat.bothSides = true;
   
   // sphere
   
_sphere = new Mesh(new SphereGeometry(10036,36), mcMat);
   
//invert faces
MeshHelper.invertFaces(_sphere);
   var 
mapping:Vector.<Number> = _sphere.geometry.subGeometries[0].UVData.concat();
   var 
i:int;
   for (
0mapping.length+= 2{
    mapping[i] 
= (mapping[i]);
     
   
}
    _sphere
.geometry.subGeometries[0].updateUVData(mapping);
   
   
_sphere.position _camera.position;
   

   
_view.scene.addChild(_sphere);
   
   
// Setup Away3D stats
   
var stats:AwayStats = new AwayStats(_view);
   
stats.5;
   
stats.5;
   
this.addChild(stats);
   
   
this.addEventListener(Event.ENTER_FRAMEonEnterFrame);
   
stage.addEventListener(Event.RESIZEonResize);
   
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
   
stage.addEventListener(MouseEvent.MOUSE_UPmouseUpHandler);
     
  
}
  
  
private function onEnterFrame(e:Event):void
  {
   
   
if (_bMove{
    _camera
.rotationY 0.3 * (stage.mouseX _lastMouseX) + _lastPanAngle;
    
_camera.rotationX = -0.3 * (stage.mouseY _lastMouseY) + _lastTiltAngle;
    
    
_vx = (_camera.rotationX _oldX)*.2;
    
_vy = (_camera.rotationY _oldY)*.2;
    
_oldX =  _camera.rotationX;
    
_oldY =  _camera.rotationY;
   
}
   
if (_hover{
    _vx 
*= .95;
    
_vy *= .95;
    
    
_camera.rotationY += _vy;
    
_camera.rotationX += _vx;

   
}
   _view
.render();
  
}
  
  
 
  
  
private function mouseUpHandler(e:MouseEvent):void 
  {
   _bMove 
false;
   
_hover true;
  
}
  
  
private function mouseDownHandler(e:MouseEvent):void 
  {
   _hover 
false
   _lastPanAngle 
_camera.rotationY;
   
_lastTiltAngle _camera.rotationX;
   
_lastMouseX mouseX;
   
_lastMouseY mouseY;
   
   
_bMove true;
  
}
  
  
private function onResize(e:Event):void 
  {
   _view
.width stage.stageWidth;
   
_view.height stage.stageHeight;
  
}
  
 }
 
   

fjckls, Newbie
Posted: 02 June 2012 08:40 PM   Total Posts: 3   [ # 3 ]

Thanks theMightyAtom for the tips. I checked your example link and I could get max 8 FPS - Im on win7, 3gb RAM, dual core 2Ghz..
Stage3D didn’t actually helped as much as I was hoping to, but I could squeeze indeed more FPS after reducing size of the video.

To invert faces I found this helper:

MeshHelper.invertFaces(_sphere); 

I’ll try to optimize more and keep you informed on the progress. If you find out something let me know too smile.
Thanks again for your help!

   

Avatar
theMightyAtom, Sr. Member
Posted: 02 June 2012 09:08 PM   Total Posts: 669   [ # 4 ]

I think you’ll find that helper doesn’t help much! ;O)
I tried it without success, so ended up reversing the UV’s as you can see.

Hopefully in a future version of the Flash player we can get hardware accelerated video into Stage3D. At the moment it’s a question having fast video playback (StageVideo), or CPU rendered video in Stage3D , as here.

It may be worth setting the frame rate of the flash movie to the same as the video, which I’m sure is less than 60fps. Despite the low frame rate in the Stats window, I think the playback is acceptable (on my machines!). You can make the browser window smaller if framerate causes jittering.

Let us know if you improve performance, without losing quality.

Cheers!

   

Avatar
Fabrice Closier, Administrator
Posted: 02 June 2012 10:43 PM   Total Posts: 1265   [ # 5 ]

Yes video for 360 is expensive. Actually using more power than in flash 10. But because the rest is faster, it feels similar.

Next to Prefab, I did a while ago an editor dedicated to this.
http://www.closier.nl/downloads/sfeerz/Sfeerz.air
I dought I will update it to f11, tho I might, if there is enough animo incorporate some goodies from it at some point into Prefab for the people doing 360 stuffs.

I did some 360 video in Away 4, and you can get higher frame rate than what you get “out of the box”. It requires more work both on geometry, uv’s and of course the material itself. Using a bags of tricks to cut down costs.
We have to focus on 4.0 atm, but just know we are thinking of this kind of cases. Obviously if we could access the decoded data it would run way faster. It’s not in our hands.

@TheMightyAtom I think you’ll find that helper doesn’t help much!
can you develop a bit? I have this class in Prefab 2 and so far it does what it needs to do. No? Do I miss something here?

   

Avatar
theMightyAtom, Sr. Member
Posted: 04 June 2012 07:24 AM   Total Posts: 669   [ # 6 ]

Fabrice, you’re right I should elaborate…
Using the invert faces on the sphere, does indeed flip the normals, but the video mapping remains backwards. So you get the same result as using bothsides=true.

I have added the invertFaces command, that alleviates the need for bothsides=true on the material. May there’s a performance boost?
It’s still necessary to flip the x-axis of the UV’s before the video shows correctly.

Cheers!

   

Avatar
Fabrice Closier, Administrator
Posted: 04 June 2012 11:21 AM   Total Posts: 1265   [ # 7 ]

Point taken: next Prefab update will have the invertUV’s u (already implemented) and so will next Away update.

   

fjckls, Newbie
Posted: 19 June 2012 01:15 PM   Total Posts: 3   [ # 8 ]

Hi, I finally finished the project - decided to stick with away 3.6, because I needed movie material class.
log in with facebook or twitter for full experience smile
Check it out here (its about drink driving):
http://www.otraiespeja.lv/

The big issue was the video quality. I put movie material on the sphere and inverted faces. Could that lead to loss in video quality?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X