picture home | art | events | music | rack extensions | downloads | pixel blog | qt_tools

omino pixel blog

pixels, motion, and scripting
david van brink // Sun 2008.11.2 22:58 // {pixel bender}

Pixel Bender: Sphere Redux

Tweaks and improvements to the previous diced sphere Pixel Bender kernel.

Just click Go. Really.

cubes04.swf

click for
http://omino.com/pixelblog/wp-content/uploads/2008/11/cubes04.swf

As before, it uses a sort of orthogonal ray tracing technique. The depth into a particular cell determines the amount of darkness. In this sense it’s a short cut for HDRI and radiosity in that, simply, the further into the “cave”, the darker it is. Seems to work.

oh, i dont know. what do you think?


david van brink // Wed 2008.10.22 20:35 // {pixel bender}

Pixel Bender: Fun With Cubes 2 (a Dicing Sphere)

Back to the cubes. This Pixel Bender generator shows a volume subdivided into cubes, and constrained to a spherical limit.

cubes03.swf

click for
http://omino.com/pixelblog/wp-content/uploads/2008/10/cubes03.swf

And here’s the source code.

/src/pixel_bender/cubes/cubes03.pbk in new window download /src/pixel_bender/cubes/cubes03.pbk to file hide /src/pixel_bender/cubes/cubes03.pbk

Can’t wait to start incorporating this stuff into After Effects CS4… but haven’t uncovered any details on exactly how Pixel Bender integrates to it. Presumably some magic parameters may tell you things like the source or dest extant, and maybe you can add “typing” information to parameters. Looking for links… since it may be a little while before I can afford to upgrade.

1 comments
Kerry // Thu 2008.10.30 08:258:25 am

SecurityError: Error #2152: Full screen mode is not allowed.
at flash.display::Stage/set displayState()
at cubes03/goFullScreen()
at cubes03/__bigButton_click()

oh, i dont know. what do you think?


david van brink // Thu 2008.10.16 23:07 // {pixel bender}

Pixel Bender: Fun With Cubes 1

In which I present instances of a family of closed-cell geometric objects which are computationally trivial to render.

The Concept

Imagine moving a plane through a three dimensional mesh of cubes.

checkerSquare320.mp4

click for
http://omino.com/pixelblog/content/2008/pixelBender/checkerSquare320.mp4

You start by rotating the plane to your liking. That is, for each pixel on the plane (since that is our rendering reference point) we rotate and translate it as we like, from (x, y, 0) to (x’, y’, z’). To find out which “cell” we’re in, we just look at the integer parts of the prime-coordinates. In the animation above, the cells have been “checkered” by whether their integer coordinates’ sum is even or odd. (Actually, I just used LightWave’s 3d checker texture function. But you get the idea.)

Drawing the checkerboard is easy. Drawing some depth in the cubes is only a little bit trickier. We need a perpendicular vector from the plane, to cast a ray, so we also rotate the perpendicular vector (0,0,1) by the same amount. Then we project that ray from the fractional position within the cell until it hits one of the 6 walls of the cube. Lastly, we give a non-optical depth cue based on how far the intersected wall is.

The Implementation

Here’s the math part of the rotation. There’s probably an easier way to get the 3-axis rotation matrix… But this works.

// concatenate three simple rotations to spinM
float3x3 spinXM = float3x3(1,0,0,0,cos(spin.x),spin.x,0,-sin(spin.x),cos(spin.x));
float3x3 spinYM = float3x3(cos(spin.y),0,sin(spin.y),0,1,0,-sin(spin.y),0,cos(spin.y));
float3x3 spinZM = float3x3(cos(spin.z), sin(spin.z), 0,-sin(spin.z), cos(spin.z), 0, 0, 0, 1 );
float3x3 spinM = spinXM * spinYM * spinZM;

float2 center = float2(400,500) / 2.0; // YUCK! hardcoded for my blog entry.
float2 oc = (outCoord() - center) / zoom; // adjust "input coordinates"

// we rotate the requested coordinate by 3 axes, giving the
// R3 point on the plane of the screen (after the mesh is turnt)
float3 p = float3(oc.x,oc.y,0) * spinM; //oc.x * axis1 + oc.y * axis2;

// perp is our viewing line, straight down from the screen.
float3 perp = float3(0,0,1) * spinM;

Here is an interactive demo of the algorithm, in Flash and Pixel Bender. (I added a full screen button, whee!)

cubes01.swf

click for
http://omino.com/pixelblog/content/2008/pixelBender/cubes01.swf

And here is the Pixel Bender kernel:

/src/pixel_bender/cubes/cubes01.pbk in new window download /src/pixel_bender/cubes/cubes01.pbk to file hide /src/pixel_bender/cubes/cubes01.pbk

And for reference, here is the template for the Flash displayer, compilable by mxmlc.

/src/pixel_bender/cubes/pbTemplate.mxml in new window download /src/pixel_bender/cubes/pbTemplate.mxml to file hide /src/pixel_bender/cubes/pbTemplate.mxml

Flex trivia: stage.addEventListener(FullScreenEvent.FULL_SCREEN,screenChange);
works from mx:Application applicationComplete because the UI and display list is all instanced, but not from mx:Application creationComplete which happens a little bit earlier.

Next up: Suppose we didn’t intersect with a simple plane… !

oh, i dont know. what do you think?



0.0398s
(c) 2003-2013 omino.com / contact poly@omino.com