Following on from yesterday's post I decided to act on my own suggestion and make a 3-channel version of the Game of Life shader. The result is here on Wonderfl and embedded below, with the full shader code as a comment at the end of the source on Wonderfl.
The code is a straightforward port of the previous shader. The first eight lines are identical except instead of adding red values it's adding all three channels at once. This makes the code more compact, showing how shaders are particularly suited to manipulating vector values (code like this would be much worse to do in ActionScript).
But while there are vector versions of the subtract and less than operations there is no vector version of the tenary operator, "condition ? value1 : value2". That has to be done component by component so the rest of the code is done a component at a time, before the values are combined to produce the vector result.
The ActionScript code this time produces an image which is randomised in all three channels (if it started with a black and white image the result would be a less efficient version of the previous shader). Because at the start and subsequently every channel is 0x00 or 0xff the BitmapData has only a colour depth of three bits or eight colours. The effect is reminiscent of art produced on old 8-bit computers, such as the Sinclair Spectrum, especially when applied to photographic art.
No comments:
Post a Comment