Pixel Bender Quirks
I just wanted to quickly document several issues I’ve had so far when developing with Pixel Bender in case anyone else runs into similar issues.
For instance, with the following code it should be obvious which input will take the background pixels and which will take the foreground, or source display object:
1 2 | input image4 background; input image4 source; |
However, the names of course make no difference since you can name them whatever you like. Just don’t make the mistake of reversing the names:
1 2 | input image4 source; input image4 background; |
Despite the names, the “source” input here will still be filled with the background pixels below your display object while the “background” input will be filled with the pixels from the display object. So be careful!
As an example, this worked for me in the Toolkit, but failed in the Flash Player:
1 2 | float3 p = float3(relativePos.x, relativePos.y, -z); p = normalize(p); |
This code, which performs the normalization, worked:
1 2 3 | float3 p = float3(relativePos.x, relativePos.y, -z); float pLength = length(p); p = float3(p.x/pLength, p.y/pLength, p.z/pLength); |
Huh.
Broken:
1 | float saturation = max(px.r, max(px.g, px.b)) - min(px.r, min(px.g, px.b)); |
Works:
1 2 3 4 5 | float maxSat = max(px.r, px.g); maxSat = max(maxSat, px.b); float minSat = min(px.r, px.g); minSat = min(minSat, px.b); float saturation = maxSat - minSat; |
Maybe I’m missing something in these broken examples, but the frustration was mostly in the fact that it all worked fine in the Toolkit, but produced a nice black image in the Flash Player. It would have been nice to at least have it broken in both places. :)
I am reading your book AS3-Image Effects and like it very much. I tried ch 7 planets.as and have a couple of questions/comments. The rotation is very jerky. I looked at the aeon.animation routine for tweeen but did not completely understand the time segmentation between jumps. If I make the image smaller (1/2 size-not much help), make the timer longer (300,000-not much help), make the timer shorter (3000-better/ok). so the question is: is there any way to control the time between redraw so the motion is smooth but yet have a long rotation period so it looks like a real planet? This would allow a parameter for redraw periods and a seperate parameter for rotation time.
Sorry for putting the question in this post but looking at your web site I could not find any place to leave a message other than on one of these articles.
BTW. AS3-Animation Keith Peters has a very nice smooth scrolling version of planet rotation – pg 351.