[Papervision3D] Rasterizing in AS3 with ByteArray
Philippe Ajoux
philippe.ajoux at gmail.com
Mon Jan 8 13:28:37 EST 2007
Hello everyone (first time sending out message),
I have been looking at PV3D for a while now, and the demo's look pretty
good.
I also have been trying to work out 3D stuff on my own for quite a while now
too, and
have recently tried my hand at it. What I got was my own little library that
can
render the PV3D Seahorse demo. In fact, it was not too difficult.
Now, this message deals with a thread from a few days ago, I believe,
talking about
the Rasterizing system presented by bytearray people. The demo is very
impressive,
but, from my experience will not particularly help with PV3D and I will not
explain why:
In my own 3D programming over the past week, I went from first displaying my
3d textured
triangles using the same method PV3D does; that is to use the Matrix to
manipulate BitmapData
and draw it using a beginBitmapFill(). That work quite fast and all was
good. However, it is
not perspective corrected, and I also wanted to try a hand at doing a
perspective corrected
texturing. To do this, have to actually rasterize the triangles by hand (in
code).
As I started to do this, I also found out that the SWFZ (that super sweet 3d
proof of concept
with the dancing yoshi) does the same thing. He actually rasterizes his
polys. After getting over
the automatic FPS drop from just displaying a 800 x 600 BitmapData in Flash
9, I was feeling
pretty good. I got a flat fill (just like the bytearray guys) triangle about
1/2 the size of the
screen to be displayed at a nice 55-60 FPS. I felt good, so I went on to
code a simple
linear texture mapper (non-perspective to start off), and that's when it all
went to heck.
The moment flash had to deal with a setPixel() and getPixel() the
performance for the same triangle
as a flat fill drop 20 FPS, down to around 35 FPS (non-browser). The issue
is not ActionScript 3.0
taking to long to loop through all the pixels, but the Flash Player to
getPixel().
For example, say this is my loop for rasterizing all the pixels:
for (.... loop through y's of a triangle )
for (.... loop through all the scan line of the triangle )
{
setPixel(x, y, texture.getPixel(tx, ty));
}
The texture.getPixel() bit slows the Player down by around 20 FPS on my
MacBook Pro.
What this long winded message means, is that, from my experience, having
PV3D rasterize it's
own polygons would not be feasible, unless you use a screen the size that
SWFZ uses (which is
too small for my liking). However, it is also true that once you have a
Rasterizer that can run
at a desired FPS displaying a polygon the size of the screen, then you can
pretty much
have any desired number of polygon displaying without any FPS loss.
Thanks for you patience and sorry if this had already been stated.
-- Phil
__ _ _ _ _
| -- | | |_| | |_| | |
| _| | _ | | | | |_
|_| |_| |_| |_| |___|
email: phil at d3s.net | philippe.ajoux at gmail.com
website: www.d3s.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20070108/a684e243/attachment.htm
More information about the Papervision3D
mailing list