GearHead RPG Sprite Dithering Tutorial

Last Updated on 2021-04-28 by Michael Horvath

Sometimes you need the benifits of having varied opacity (such as when creating effects that are overlayed on top of sprites, like fire or smoke), but for technical reasons can’t utilize 8-bit transparency. In these cases you can use the information in the alpha channel to dither the image in order to approximate the effect.

The original 32-bit image, with mask (alpha channel)
The original image’s 8-bit mask
The original 32-bit image, with mask removed
The modified and dithered 1-bit mask
The final result

Step one: Generate an image with an alpha channel

You can use a ray-tracer, such as POV-Ray, for this. Make sure it utilizes the alpha channel for the transparency information. Using anti-aliasing also can’t hurt since there’s no colored background for edges to bleed into.

Step two: Decrease the color-depth of the alpha channel

Open your image in an image editor, such as GIMP. Decrease the color-depth of the alpha channel (a.k.a. the mask layer) to 1 bit (2 colors). (You may have to export the alpha channel as a new image, first.)

Step three: Remove all information masked by the alpha channel

Select all pixels in the alpha channel that aren’t white. Apply the selection to the other channels and cut these pixels to make them pure blue (RGB 0,0,1).

GearHead Appender
Screenshot of GH Ditherer

Step four: Remove the alpha channel and save your image

Delete the alpha channel (the mask), as it’s no longer needed. Then save your image.

Example ImageMagick command-line

Here’s an example command-line for ImageMagick that can be used in a batch file to automate the process:

set InName="Walls_Arena11.png"
set OutName="Walls_Arena11_output.png"
convert %InName% ( -channel A -ordered-dither 2x1 ) ( -compose CopyOpacity -composite ) %OutName%
convert %OutName% ( -background blue -flatten ) %OutName%
convert %OutName% ( -transparent blue ) %OutName%

GH Ditherer is a frontend program I created for ImageMagick. It will perform the above commands on any image file you select.

Proudly powered by WordPress. Theme: isometricland by Michael Horvath based on GPLv2 or later.