peter nitsch.net

peternitsch.net

Raytracing Wada basins in Flash

Wada basins
Check it out!
Source code

Getting into the Christmas spirit, I thought I’d play around with raytracing reflective spheres to produce the fractal known as Wada basins. It’s an old technique that can be easily reproduced physically by using four mirrored Christmas ornaments stacked in a pyramid. To be honest, the idea came from seeing the mirrorball Ralph picked up to use as a lightmap for Triangle3D.

I bought a set of mirrored ornaments for our tree and set them up in a pyramid:
Ornament pyramid

The fractal appears through the center:
Fractal

I’ve been wanting to write a simple raytracer (the Alchemy version I posted a while back was a port of PixelMachine) in pure AS3 for some time. This experiment marks the first steps towards that goal. You can check out the source code. It’ll grow over time as I clean up the structure and add optimizations.

The first AS3 test draws the image line by line to avoid some serious stack overflows. Camera positions, lighting, reflectivity, and other values can easily be changed within the source. I’ll draft an API over time. The result is a 4K swf:
AS3 version

An Alchemy version of the same logic achieved much faster render speeds (minus the line drawing), but the resultant swf was well over 100k:
Alchemy version

An attempt at simple interaction with the Alchemy version:
Interactive

1000×1000 pixel render:
1000x1000

The next step will be to write a WebGL version and compare it to the Flash speeds.

Category: Alchemy, Flash

Tagged: , ,

3 Responses

  1. makc says:

    this looks remarkably similar to serpinski triangle.

  2. bigfish says:

    nicely done… very Xmasy. I also saw the bottle of Keiths.. you are so totally busted being Canadian :)

  3. This is really great. It’s a wonderful oldskool effect and converts the video to another level. I wished there would be an effect in my video editing software to give own productions such a “hacker” look.

    respect.

Leave a Reply