/colorpaletteramp

A Houdini HDA that creates a ramp based on a color palette from an image using k-means clustering.

Color Palette Ramp

A Houdini HDA that creates a ramp based on a color palette from an image.

Compatible with Houdini 18.0+

You do not need to download the repo for the tool to work.

This node can be used on its own to create ramps to use elsewhere, or to modify the color of the incoming geometry. It uses k-means clustering in Lab space to group visually-similar colors into a set number of clusters, resulting in a color palette from the input image.

If you are using a Houdini build < 18.0.460, and you are using an ACES workflow, be sure to tick on "Convert Image to ACEScg Colorspace". If you are using 18.0.460+, this step is done for you.

  • 18.0.460+ includes the hou.Color.ocio_activeDisplays() method. If you're using build 460 or later, the ACEScg toggle will be automatically enabled for you if necessary according to your OCIO environment.

Overview Video

Features

Input Detection

Color Palette Ramp can take an input, but does not require one. You can use the ramp all on its own if you want to channel reference it elsewhere from within Houdini.

Gif of adding/removing input

# of Stops & HSV Sorting

You can control the number of swatches you want your ramp to have. 5 - 8 is usually plenty!

Choose to sort by Hue, Saturation, Value, or nothing at all.

Gif of sliding stops and sorting

ACES Detection

Color Palette Ramp detects your environment's OCIO settings, and automatically enables sRGB -> ACEScg conversion.

Gif of dropping the node down and checking the ACES box

Luma Key

Key out luminance areas that don't interest you to avoid having too many overly dark or bright swatches.

Gif sliding the luminance min/max values

Clustering

VEX or Houdini Cluster SOP

Under the hood, the color clusters are calculated using the K-Means algorithm. You can choose between a VEX implementation or the Houdini Cluster SOP. All calculations are done in Lab space using Delta E 76. In the future, this would hopefully be changed to Delta E 2000

Optimization Tweaks

You have control over how accurate the resulting palette is. The defaults are balanced between quality and speed, leaning a little more towards quality. You can drastically downsample the incoming image and still get pretty good results.

Gif of clustering settings

Output Colors Array

You can output the color swatches as a Detail Array attribute for use elsewhere.

Image of Export Array Setting

Image of wrangle using array

Gif of particle system picking from the array

Ramp Updates Automatically

All changes to the ramp update automatically, so you don't need to press anything extra. The ramp creation itself is not time-dependent, so inputting animated geometry should not incur much of a performance hit

Help

  • Help card and tooltips provided just like normal Houdini help.
  • Embedded example (RMB > Examples)

Gif of RMB Examples

Update Houdini 19.0: It appears SideFX has removed this feature, and it was a little buggy in older versions. The extra colorpaletteramp_example definition has been removed, and replaced with a button to spawn some examples from the node directly.

New Example Button

Installation

This repo acts as a Houdini Package.

  1. Clone or copy this repo to $HOUDINI_USER_PREFS/packages (create the packages directory if it does not exist).
  2. Move or copy colorpaletteramp.json into $HOUDINI_USER_PREFS/packages
  3. Launch Houdini