Ray tracing with Pixel Bender using JITB

RTTerrainWith Flash on the Beach behind us and having had time to process everything, I can safely say it may have been the best edition yet. A great way to get inspired and meet old as well as new friends, and every year it becomes harder to leave. So thanks John for organizing yet another kick-ass festival (yeah it’s really more like a festival than a conference ;) ).

One of the things I swear by every year, is that you haven’t experienced Flash on the Beach if you didn’t catch Joa Ebert‘s session, especially since he started to work on his Apparat suite. Needless to say, I was very honoured when he asked me to contribute some Pixel Bender shaders to show his new JITB player running on the GPU. For those not aware of JITB, it’s essentially a lean & mean Java-based Flash player, with all the niceties the Java runtime provides. Read more about it here.

Results

I ended up writing two ray tracers (or rather, ray marchers).

Yeah, yet another quaternion Julia set. I mentioned last time that they look much better raytraced, and I hope you’ll agree. The sound synching is as interesting as I could get it with only left/rightPeak being supported and a limited amount of time :)
Based on the paper “Ray Tracing Deterministic 3-D Fractals” by John C. Hart et al.
Music: Aphex Twin – Xtal

It’s a bit hard to tell, but the terrain marching also has dynamic lighting and shadow casting. The frame rate in the video is actually quite bad, due to the screen capture.
Based on Inigo Quilez’ Terrain Raymarching article

Source

In the spirit of sharing, happy bunnies and double rainbows OMG, I provided the source to these projects, so you can run it yourself.

Get it here!

Of course, you’ll need to run it using JITB. Check Joa’s post on how to get things running.
Also, the download is a bit heavy due to big-ass terrain images (just because, y’know, now I can ;) )

DISCLAIMER: run it at your own risk. If your machine/GPU is known to overheat easily, it’s best not to try it at all (Case in point – sorry dude ;) ).

Keep in mind, it’s still Pixel Bender compiled for the Flash Player, so all the limitations in that field remain. That of course means no loops. As a result, the Pixel Bender shaders themselves are near-comical (there’s an huge unrolled double loop in the case of the Julia set, for example). I wasn’t aiming for the most optimized code either, but rather show how much difference JITB can make. So please, do take it with a grain of salt :)

Noteworthy, JITB actually recognizes “copy/paste unrolledness” and recompiles it to loops: very cool!

Finally

It’s been great fun to work on it, and getting to annoy Joa with feature requests ;) Seeing how these shaders run in real time is still very thrilling to me, when you consider the normal Flash Player takes up to 2 minutes per frame! It’s not fair to compare CPU to GPU, but still…

In closing, many thanks and humble bows to Joa for inviting me and making my attempts a part of his session, as well as his hard work on Apparat! I encourage anyone to check out his work and contribute!

5 thoughts on “Ray tracing with Pixel Bender using JITB

  1. Thats pretty neat! The results look great!
    Is it really still pixel bender at runtime or is it compiled over to a glsl shader or something like that ?

  2. Hey David,

    what a nice blog post. Thank you again for all the work you have put into this and all the bugs you pointed me at. It was great fun working with you!

    Best,

    Joa

  3. dominic: It is a normal SWF with a normal PixelBender shader. You can run those files in the Flash Player and wait 2min for an image to show up.

    JITB recompiles the PixelBender code at runtime to GLSL which the “loop”-detection as David said.

  4. Pingback: Apparat 1.0 RC7 Is Here « blog.joa-ebert.com – Blog of Joa Ebert

  5. zoinks! I want to do this in Broomstick! Amazing work. I have an open thread on procedural terrain in Broomstick on the Away3D Google group. Would love to have your feedback on it.

Leave a Reply

Your email address will not be published. Required fields are marked *