Generating spheres with Pixel Bender. February 6, 2009 at 10:17 am
It all started last week when John Nack told me that NVidia arranges a Pixel Bender contest. Good idea I thought and immediately begun scripting some Pixel Bender stuff I had already on my mind for some time past. But hard luck, the contest participation is opened to US residents only, so I can´t take part! Whatever, at this point in time when I noticed that limitation I was shortly before completion with my entry, therefore it would be a shame to withhold my results…
3D Spheres generated with Pixel Bender
My initial thought was, what if we could use a shader to generate spheres and beyond that, manage all their behaviours like xyz-rotations, texture segments, scale factors a.s.o within the kernel? Quite an interesting challenge.
At first I divided the tasks into two pbk´s. The first shader applies stereographic projections to an image, the basis for the texture mapping of the spheres at a future date. The second Pixel Bender kernel handles all the mathematics that are needed to compute and build the spheres.
Well, let´s see what´s it like?
In my first output, you can use keyboards “UP” and “Down” keys to roll the sphere along the Z-axis up and down the road (maybe you´ll have to click on the stage first to focus the swf).

Launch || (download the sources)
The previous example makes use of only one axis and rotation direction , but as I said before, the shader can manage all three axes. Therefore I reused my 3D-Metaballs snippet, replaced all the 3D related stuff and let my shader take over all computations. As suspected, the sphere kernel is very effective in performing all the related math and administrating the spheres rotations-, movements- and scalings. It even can handle more spheres than it´s “just” in Flash executed Metaballs counterpart.
Most recently one more thing concerning the proper mappings of the textures. You must apply a stereographic projection to the image you want to use as map at first to receive accurate mappings. Feel free to use my “asp-shader” for this purpose (download the sources). Taken by itself, this shader achieves a lot of interesting results. Just move your mouse to affect warping and repositioning of the current projection. Activate/-deactivate zooming and xy-replication by simply clicking on the stage (mouseDown).
Gee! It´s a pity that NVidia´s contest is limited to US residents only, but developing all that stuff on the occasion of taking part was great fun anyway and definitively worth while.
Enjoy!




hehe spheres are fun, right :D
couldnt manage to apply the rotation to the texture, so i think i’ll have a look at the steorgraphic projection
keep on rollin
You bet! ;)
Without applying a stereographic projection to the image you want to use as texture onto the sphere, the mapping will fail.
if you stare at red ball for a while, you’d notice random texture strips come and go. seems like some bug to haunt down.
it´s not a bug it´s a feature… ;)
…yeah, of course a bug. thx for reporting.
[…] actionscript microcosmos » Generating spheres with Pixel Bender. (tags: flash actionscript pixelbender) […]
I’m trying to use this with an equilateral panorama to produce an animated wee planet. is there a configuration of the parameters that will produce this or is this plugin not designed for this?
You have some nice filters here, very cool, I just made my first one its not as complicated as yours but its my first attempt. You can see it here http://chris-martin.co.cc/?p=69