View Full Version : 3D Raycasting in Flash9
Bad Sector
08-27-2008, 04:08 AM
Here is a small raycaster i did in Flash9/haXe (http://www.haxe.org/) over night. Nothing really mindblowing, or never-seen-before (i've actually seen better stuff done using Flash). However i think its one of the few raycasting engines in Flash that doesn't have horrible artifacts or accuracy issues with distant walls. Also most people just render walls, i also render sprites :-P. And its 9kb including textures :-).
Anyway, tell me your average/worst FPS (see at the top-right corner) and your system specs :-).
http://gimme.badsectoracula.com/rayfaster/
Samji
08-27-2008, 06:10 AM
Looks pretty cool. Reminds me of Wolf 3D. That would pretty cool in Flash actually.
Mr.Fibbles
08-27-2008, 07:32 AM
If I get close to the sprite I drop down to like 170~180 but otherwise I am up around/above 200.
This is on my work computer:
Dell Optiplex 745
Core 2 Duo (2.13)
2GB RAM
ATI Radeon X1300PRO (256mb)
Crosma
08-27-2008, 08:25 AM
I haven't messed around with Flash 10 stuff yet, but it's got rudimentary 3D acceleration support, to compete with Silverlight. Should be pretty cool.
This raycaster thing is pretty cool. Kudos.
Got 60 FPS on my 1.2GHz Linux laptop in Firefox. The low-ish FPS is probably down to the Linux version of Flash being slow as hell at writing the graphics buffer to the screen. Although X11 is probably partially to blame. Flash 10 is going to use 3D acceleration to write to the screen, so it should be hella faster.
I get around 200 with the lowest dip of 198 or so. But it's very constant with a couple of peaks above 220. It's on my laptop which is a Core 2 Duo 2.4ghz running Vista.
Either way this is very cool. Any chance of releasing the source code/fla? Would love to see how it's done.
Bad Sector
08-27-2008, 03:21 PM
@Crosma:
Maybe your video drivers? My EeePC (which runs Linux and has an Intel Celeron -officially- underclocked at 600Mhz with some intel GMA card) gets around 30fps. I will look intro Flash 10's 3D stuff once haXe (the language i use to produce SWF files) supports Flash 10 :-). But even when it comes out, i'm not sure if i'll use it immediatelly since it will take a while to be widespread (even Flash Player 9 which is available for years isn't the majority).
@Samji:
http://www.glenrhodes.com/wolf/myRay.html. This one is playable (not mine) but it has a very low resolution and its kinda blurry.
@ADM:
Its your pretty standard raycaster. This tutorial is probably the best on the net (http://www.permadi.com/tutorial/raycast/) about making a raycaster. I didn't made this in Flash, but in haXe (http://www.haxe.org/) an AS3/Java-like language which supports generation for Flash 6 to 9, PHP, JavaScript and its own server-side VM module for Apache (basically its an all-in-one web language :-P). So there isn't any .FLA available (i don't even have the Flash IDE).
Also the textures are embedded in the source code (in a class) using a small tool i wrote that reads PNG files, converts them to a 8bit bitmap and stores that bitmap in an array (which is then written in a generated haXe source code file). Since the texture data is "packed" in a single array, the pixels are 8bit (one byte per pixel) and the whole SWF is solidly compressed, this produces smaller files than if i was using a separate file per image/texture.
Yatta
08-27-2008, 05:49 PM
~150 FPS
Win XP
Athlon X2 4200+
GeForce 7800 GT 256MB
2 GB RAM
Mr.Fibbles
08-27-2008, 06:05 PM
~110
Pentium D 805 Dual Core (2.6)
GeForce 7600 GT (256 MB)
2 GB RAM
I'm actually surprised I am getting lower specs considering that something like Spore Creature Creator won't even install on that work machine (video card not supported)
Bad Sector
08-27-2008, 07:03 PM
@Mr.Fibbles:
It uses only the CPU.
I added floor casting (textures in floor). It might go a little slower now.
Yatta
08-27-2008, 07:20 PM
~130 with the floor textures.
Crosma
08-28-2008, 05:30 AM
@Crosma:
Maybe your video drivers? My EeePC (which runs Linux and has an Intel Celeron -officially- underclocked at 600Mhz with some intel GMA card) gets around 30fps.Nah, the Linux version is just crap and has serious syncing issues on a lot of systems. I managed to fix mine by forcing OSS.
Bad Sector
08-28-2008, 06:19 AM
I've added a bunch of new stuff in the engine:
Floor/ceiling textures (they use the same code now) with textures taken from the tilemap (basically three tile maps are defined - one for ceiling, one for walls/entities and one for floor).
Multiple sprites (using fast but inaccurate sorting based on the rays being cast)
Map data loaded from special resources (generated using a plugin i wrote for a tilemap editor i'm making - check here for more info (http://www.badsectoracula.com/projects/mapas/))
Collision detection with sliding response
WASD keys as an alternative to arrow keys
Obviously the rendering slowed down a bit (from ~200 fps in my machine to ~160fps, although it fluctuates between this and 200 depending on what is in view)
Mr.Fibbles
08-28-2008, 10:56 AM
@Mr.Fibbles:
It uses only the CPU.
I guess that means the Core2Duo is better than the Pentium D despite the processor speed.
Averages between 100~120 FPS on the Core2Duo now.
Yatta
08-28-2008, 04:06 PM
I've added a bunch of new stuff in the engine:
Floor/ceiling textures (they use the same code now) with textures taken from the tilemap (basically three tile maps are defined - one for ceiling, one for walls/entities and one for floor).
Multiple sprites (using fast but inaccurate sorting based on the rays being cast)
Map data loaded from special resources (generated using a plugin i wrote for a tilemap editor i'm making - check here for more info (http://www.badsectoracula.com/projects/mapas/))
Collision detection with sliding response
WASD keys as an alternative to arrow keys
Obviously the rendering slowed down a bit (from ~200 fps in my machine to ~160fps, although it fluctuates between this and 200 depending on what is in view)
I get around 100-110 FPS now.
LeadBullet
08-29-2008, 12:00 AM
I get between 75-120 in normal use with my usual programs running.
Athlon XP 4000+
Bad Sector
08-29-2008, 02:37 AM
New version, i added doors (togglable - like in Duke, not timed like in Wolf), and "thinkers". These are objects that are attached to entities in map load time and provide the logic part (the bouncing balls are provided by a thinker test). Also did proper sorting for entities.
Samji
08-29-2008, 09:39 AM
@Samji:
http://www.glenrhodes.com/wolf/myRay.html. This one is playable (not mine) but it has a very low resolution and its kinda blurry.
Thanks. A good find!
LeadBullet
08-29-2008, 11:19 PM
On the updated one my FPS went from 75-120 to 100-150ish. I watched carefully and it never went under 100.
Bad Sector
08-30-2008, 12:21 AM
Hmm, i did changed some parts which should speed up things but on the other hand i added lots of others which i expected to slow down things too (like proper entity sorting). It could be the more "cramped" nature of the new map (less spacy rooms which leave less floor and ceiling to be rendered - these are the slowest parts of the raycaster), but then again i added much more entities which should provide a bit of balance.
Of course hearing that the rendering is faster now is only a good thing :-). But i've uploaded a new version with a wider room with more entities to check.
Mr.Fibbles
08-30-2008, 10:09 AM
Current FPS on Pentium D 805: 75~100
LeadBullet
08-30-2008, 11:21 PM
I get 96-102 sitting at the start point.
In that room with all the statues and tons of bouncing balls I'm around 86-92
Superczar
08-30-2008, 11:29 PM
Pretty cool man, lowest drop for me was down to between 110-160 in the room with the balls.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.