Dithering Shader

Description
Update: The shader package now includes image effects which streamlines their usage in Unity Pro.

These shaders replace the colors on the screen with dithering patterns of one or more indexed colors taken from a palette image (by converting the original color into a XY coordinate on the palette image). The theoretical maximum number of dithering patterns is 16^3.

The palette images are generated with the CreatePalette editor component in Unity3d. The dithering algorithms used in color selection for the palette images are based on code and algorithms by Joel Yliluoma. A dithering pattern with over 2 colors uses the gamma-corrected algorithm, while an alternative algorithm is used for dithering patterns with 2 colors.

The shaders work best at low resolutions and DOES NOT PIXELIZE the screen. However, they will work in Unity3d Free since it's not a traditional Image Effect.

Included shaders:
 * Normal/Diffuse
 * Normal/Diffuse Simple
 * Normal/Unlit
 * Normal/Unlit Simple
 * Cutout/Diffuse
 * Cutout/Diffuse Simple
 * Cutout/Unlit
 * Cutout/Unlit Simple
 * ImageFx/Diffuse
 * ImageFx/Diffuse Simple

(The Simple shaders have a fixed dithering pattern with max 4 colors, but uses one less texture Sampler)



Usage
Download and extract in the assets directory: [[Media:DitheringShaders.zip]]


 * 1) Use the CreatePalette component to create a palette image, or use one of the retro computer palettes included in the archive
 * 2) *Mixed Color Count: The number of colors to mix in a dithering pattern
 * 3) Apply one of the Palette Shaders to your material
 * 4) Configure the shader
 * 5) * Base: The main texture
 * 6) * Mixed Color Count: The number of mixed colors in your palette (rows of 16x16 pixel squares)
 * 7) * Palette Height: The palette image height in pixels
 * 8) * Palette: The palette image
 * 9) * Dither Size: The size of the chosen dither image
 * 10) * Dither: The dither pattern image (With the red values 0 to 254)

The textures used for both dithering patterns and palettes should be configured like this:


 * Texture Type: Advanced
 * Generate Mip Maps: Unchecked
 * Filter Mode: Point
 * Format: RGB 24 bit
 * Size: Power of two

To use the shader as an image effect: Camera > Add Component > Image Effects > Other > Dithering or Dithering Simple.