Thursday 19 April 2012

Pixel Bender bug

The circular gradient fill shader I wrote yesterday took more time than expected as for a while it would not work: more specifically it worked fine in Pixel Bender Toolkit but not in Flash. And it failed in a particular way: on use it would instantly lock up rather than fail with an error or produce the wrong result.

Looking at the code the only thing fundamentally different in this shader from ones I'd written before was the extended conditional block that decided which quadrant the point is in and so which pair of colours were being interpolated. The key variable in this section was the dir variable, which was being read and updated. So I changed it so it was not being updated, replacing this use with the no longer needed dir2, and it worked.

I posted both versions of the shader code to the Pixel Bender forum

And it seems it is a bug in Flash's pixel bender implementation, though not one that will be fixed soon. At least it's a simple workaround. It's a bit surprising it's not been encountered before, but this shows perhaps how underused Pixel Bender shaders are in Flash.

No comments:

Post a Comment