I started playing around with Adobe's Pixel Bender, the image processing language that will be integrated into Flash 10. Pixel Bender lets you make things like custom filters and blend modes, so I'm sure we'll see all kinds of cool effects pop up.
After reading through the Pixel Bender spec, I was impressed that it had good support for conditionals and loops, which is a tough spot for these shader languages. So what do I do? Push it to the max and make a raytracer, of course. :)
You can download the source .pbk file here. You'll need the Pixel Bender Toolkit to check it out.
It's your run-of-the-mill raytracer featuring ambient, diffuse, and specular lighting, reflection, and shadows. There are a few sticking points I had to work around. For one, there's no recursion in Pixel Bender, so spawning a tree of rays from a single ray would be tough. This rules out having objects that are both reflective and refractive, for example. Secondly, there's no indirection. This makes it difficult to have different type of primitives, so I'm rendering spheres only.
The Pixel Bender toolkit renders using the GPU, so its really cool to see the picture update at 60fps. :) It's even more awesome to think that this could run inside Flash Player 10! Unfortunately, it looks like that's too good to be true. For one, Flash 10 only supports a subset of the Pixel Bender spec. You could work around this, but even then, all signs point to Flash 10 running these shaders on the CPU only. Setting the Pixel Blender toolkit to run in CPU mode slows the raytracer to a crawl. :(
Watching the GPU do all this crazy stuff makes me wonder about the future of graphics hardware. As we add things like branch logic to our GPUs, they become more and more like a generalized CPU. Will we get to a point where the GPU/CPU distinction doesn't even exist, and your "graphics card" is just used as another core? Or will the GPU continue to be distinct as a very specialized, parallel number cruncher? I'm not really a hardware guru, so maybe I'm way off base here.
I'll be at San Diego Comic-Con this weekend, at The Behemoth booth. Stop by and check out Castle Crashers. :)
JimmyDallas
That's mighty spiffy that pixel bending