Monday, 4 November 2013

Shadow palette

For Chaos Guns we decided to create a system of dynamic shading, which has some restrictions for us as graphicians. The basic principle of this shading is that we use only the upper 128 colors of the palette for drawing, lower 128 colors are used for shadows. How does this work?

Well, lets illustrate it on an example: a character is a figure, that casts a shadow. This means the figure is drawn in bright colours out of the first 128, the environment is also drawn in these 128 colours.

Shadow silhouette is drawn in a dedicated colour, that we have specially for this purpose and that is transparent, but what is beneath this silhouette is in fact dimmed for given RGB value and creates a shadow. In practise - character stands on a bright green lawn and casts shadow. Lawn uses various patterns of light green values. The shadow affects these green colours beneath itself. Pixels affected by this shadow are darkened (their RGB value is decreased). Voila - shadow is created!

In our game everything can cast shadows, all the objects (that have to have their shadow silhouettes drawn in dedicated colour) and also buildings, that do this automatically. This allows us to use dynamic shading, we can concentrate ourselves to creation of a level map and do not need to invest our time for manual shading using darker tiles.

Also allows objects - including sprites - to be in shade of other objects. So when character enters the shadow, that is cast by a building, he is shaded pixel by pixel exactly where it is needed. Isn't it great?

On the other hand it consumpts CPU time and can slow down the game on weaker configurations, so the whole shading can be switched off when needed, even during the game. But if you have your Amiga powerfull enough, we believe this small nice feature can contribute to have a better gameplay experience.

No comments:

Post a Comment