I wrote two new Shaders today. One is for a screen that's not in the game yet, which the Shader will be a fundamental part of. As the Shader is rather complex I wanted to write it first to see if what I wanted to do was possible. It seems to work, so now I need to write the code for that screen.
The second is much simpler. It does edge detection on the layer I added yesterday, to highlight the boundary of the region indicated. The Shader code is very straightforward and it took much less time than either of the other Shaders I've done for this game.
What's interesting though is that as soon as I realised that I wanted to add something like this I started thinking of how to do it using a Shader, not using BitmapData functions. The latter is probably possible though it wouldn't be easy, and would require quite a number of steps. The ShaderFilter only needs setting up once (the brightness and colour of the effect are exposed) and is applied like any other filter as that layer is redrawn or composited.
It was made much easier by the Pixel Bender Toolkit. To see how it would work with the layer in-game I could just load up a screenshot of the game I took earlier and experiment with the Shader until it did what I wanted, finally adding parameters so I could also adjust it in game.
No comments:
Post a Comment