examples of render to texture?

Software: Away3D 4.x

thatflashdude, Newbie
Posted: 21 October 2012 02:54 AM   Total Posts: 19

i am at a loss on how to extend or modify View3D to render to a texture.

I am trying to simulate multiple cameras in a view. Basically i want to create a plane whose texture will be the rendering of another cameras view. in my enterframe loop i want to switch the camera positions such that it first looks at the scene i want to render to texture..then changes the camera position to the plane and applies the new texture. the result would give me freedom to render multiple camera angles using one camera within view3d (the reason for this is ipad doesnt support more than one level of stage3d which seems to be a requirement the way away3d view3d is setup)

so ..are there any good examples someone can share to
1. override the basic render function so i can render to texture
2. efficiently update a planes texture so it will display at best performance

thanks!

   

thatflashdude, Newbie
Posted: 22 October 2012 08:26 PM   Total Posts: 19   [ # 1 ]

bump!

any ideas anyone? id love to figure it out on my own if i could have some pointers?

   

Avatar
theMightyAtom, Sr. Member
Posted: 23 October 2012 07:27 AM   Total Posts: 669   [ # 2 ]

The Simple way….

You can do this with the standard framework, though it would be heavy to do it every frame. If you’re going to be looking at 4 cameras all the time, I would have the 3D window in the background, not visible and in a size that is a quarter of the screen size.

From there you can change camera angle/render out to bitmapData/ change camera, render again, etc. You don’t necessarily need to render these back to your 3D scene, but that depends on the exact application.

The screen capture code for Away3D has changed over the different versions and I have to admit I haven’t use it in Gold yet, but it goes something like this…

var bitmapData:BitmapData = new BitmapData(yourview.widthyourview.height);
            
yourview.renderer.swapBackBuffer false;
yourview.render();
yourview.stage3DProxy.context3D.drawToBitmapData(bitmapData);
yourview.renderer.swapBackBuffer true;
                        
var 
bitmap:Bitmap = new Bitmap(bitmapData); 

(Thanks Ivan…  http://away3d.com/forum/viewthread/3375/ )

As for you camera angles you can either move the camera to each new position before render, or you can create 4 cameras and assign each one before render…

yourview.camera camera1

Gotcha: In the “Pepper player”  (Googles version of Flash Player) for Chrome, there is a bug which can result in the stage3d instance not being captured, but as you are targeting iOS you might not have to worry about that.

OK, so that was the simple way!
The alternative is to write your own shader within the Away3D framework.
Might sound like a tall order, but you might want to check out the new Reflective material in dev branch. That renders a cubic map from a fixed position in the scene and then uses that within a texture, in realitime, in order to provide realtime reflections. What you want to do is actually very, very similar, i.e. render camera view, and use as texture on the GPU.

Good Luck with that, and if you manage it, don’t forget to share smile

 

   

thatflashdude, Newbie
Posted: 23 October 2012 04:46 PM   Total Posts: 19   [ # 3 ]

thanks alot for the new info..my quest continues!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X