Page MenuHome

Add colormap compositor node
Needs ReviewPublic

Authored by Lucas Malo Bélanger (lucas92) on Nov 3 2020, 11:55 PM.

Details

Reviewers
None
Group Reviewers
Compositing
Summary

Blender generates a full-color image when rendering. This can be a problem for color restricted applications, where the automatic color quantization does not create good results. A solution is to apply dithering, from wikipedia:

Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images.

Right now, an external image processing software is required to create such an effect. To automate the pipeline, ImageMagick could be used, but it requires a script and depending on the platform, the use of command line vs shell can create compatibility issues, especially with commands that requires special characters (',"). I've personally encountered behavior differences between using imageMagick in Powershell or cmd due to the different methods of interpreting the command arguments. Gimp also has a color remap function, but the percentage threshold is limited and using it in an automated requires a special setup.

With this compositor node, Blender can be used as a pipeline to automate color restricted graphics that are present in old games. The limitation of such a solution is that:

  • The node has to be the last before the compositor node as it ensures that all colors are in the given palette. Otherwise, if you add nodes between the compositor and the color remap node, it is not guaranteed that all colors are part of the palette.
  • The image output Color Depth settings has to be set to 16bits and to PNG type to ensure that all colors are part of the palette. When not using those settings, colors can be very slightly different to the one in the palette. For example, (0,0,0) vs (0,0,0.001).
  • Right now, only the FloydSteinberg dithering method is implemented. In the future, there could be a Positioned dithering method as it produces constant artifact over the image size which is preferable for animations.

The dithering looks like this right now:

Diff Detail

Repository
rB Blender
Branch
feature/colormap (branched from master)
Build Status
Buildable 11090
Build 11090: arc lint + arc unit

Event Timeline

Lucas Malo Bélanger (lucas92) requested review of this revision.Nov 3 2020, 11:55 PM
Lucas Malo Bélanger (lucas92) created this revision.

Revert changes to alphaOver.c

Rebase to origin master

Put threshold slider as first element on the node

Hi please fill out your patch description, the wiki has some guidelines on what to include there.

Lucas Malo Bélanger (lucas92) edited the summary of this revision. (Show Details)

Preserve the alpha value when dithering

Hi Thanks for the patch. I do see this as an Image IO issue, and not a compositor issue/feature. You also mention restrictions on how to use the node that points into this direction. Have you researched on adding this to Image IO. Adding it there doesn't need to setup a compositor nodetree to use this feature.