LJYC

Munsell → RGB2025

A UE5 material node plugin

When you adjust a material color in Unreal Engine 5, the RGB numbers are the three primary channels; if all you want is to raise the lightness without changing the hue or how vivid the color is, that is hard to control by feel with sliders. The Munsell color system splits color by human perception into three dimensions, hue, value and chroma, which matches the intuition of color work better, but the Material Editor has no native way to pick a color by Munsell notation.

To solve this small problem I wrote a UE5 plugin that adds a Munsell To RGB material node: choose a hue, value and chroma in the Details panel, and when the material compiles it looks up the table and outputs the matching linear RGB constant; if the chosen combination falls outside the sRGB gamut, compilation reports an error and tells you the maximum chroma available in that row.

The plugin’s 1625 colors arranged as a Munsell color solid: hue goes around the central axis, value goes up, chroma goes outward, and every chip is a color from the table. The line in the middle is the neutral axis. Drag to rotate.

Chapter 1

Picking colors by Munsell notation in the Material Editor

Munsell notation describes a color with three parameters: hue is the kind of color, value is how light or dark it is, and chroma is how saturated, usually written like 5RP 4/12. Munsell To RGB is a material expression node in the material graph (the node’s basic template follows the open-source CustomMaterialNodeTemplate), and its Details panel offers three drop-downs: 40 hue steps, value 1 to 9, and even chroma values 2 to 26.

Once they are set, the node outputs the color’s linear values in sRGB primaries, which can be connected straight to Base Color. Linear values are proportional to the physical intensity of light and have no display encoding; they are the number space material shading computes in. The node title shows the current cell: the (RP50, V4, C12) in the screenshot is 5RP 4/12 (internally the plugin multiplies the hue number by 10 to form the enum name).

  1. 1The three drop-downs in the Details panel
  2. 2The node and its color preview, connected to Base Color
  3. 3The preview sphere in Unlit view, unaffected by lighting
Unreal Engine’s Material Editor: the Munsell To RGB node is connected to the material’s Base Color; the Details panel at the lower left has Red-Purple 5.0, Value 4 and Chroma 12 selected, and the preview sphere at the upper left is red-purple. 1 2 3
The Material Editor.

Chapter 2

Generating the lookup table offline, and a compile-time constant

A Munsell notation chosen in the material graph is a static constant, so there is no need to put color space conversion into the shader and compute it every frame. I therefore moved all the data processing offline, before the build, so that runtime pays no extra conversion cost. The full data chain has three stages:

5RP 4/12

The 1943 Munsell renotation data (Newhall, Judd, Nickerson)

The spacing of colors in the Munsell system is laid out by human perception; the 1943 renotation gave every notation xyY chromaticity coordinates under Illuminant C, a numeric basis it could be computed from.

RIT’s 2010 real_sRGB table

In this table the RIT Munsell Color Science Laboratory did the conversion from xyY to XYZ, moved the white point from Illuminant C to sRGB’s D65 with the CIE CAT02 chromatic adaptation, and then converted to sRGB values. Cells with any channel below 0 after conversion were removed entirely, leaving 1625 of the 2734 colors; channels above 1 were clipped to 1.0. The CSV in the plugin repository matches this table cell for cell.

Offline linear decoding and C++ table generation (Data/MunsellsRGBToRGB.py)

The sRGB values in RIT’s table are display-encoded and have to be decoded back to linear space before they can be used in material math. I wrote a Python script that, before the plugin is built, decodes each channel with the transfer function of the sRGB standard IEC 61966-2-1 (c / 12.92 when c ≤ 0.04045, otherwise ((c + 0.055) / 1.055)^2.4), generates 1625 C++ statements that are compiled into the plugin, and at the end checks that every hue has exactly 9 values and that the total matches.

c ≤ 0.04045c / 12.92otherwise((c + 0.055) / 1.055)2.4

The horizontal axis is the sRGB value from the table; the vertical axis is the decoded linear value. The three dots are this cell’s R, G and B.
Hue5RP
Value4
Chroma12
Linear RGB

Every generated line does the same thing: it takes the small “chroma → color” table for the hue and value, and adds this cell’s linear value to it.

The node’s Compile() looks up the table when the material compiles and writes the result into the shader as a single three-component constant: in the Stats panel the Base pass shader is at 164 instructions without the node and 165 with it connected, with no color space conversion instructions at all. The table is a TMap nested three levels deep: hue, value, chroma. The data is sorted to begin with (sortedness is the precondition for a lot of silver bullets), so it could also be generated as a static array and searched with binary search, which would skip the heap allocations of building the table when the module loads. I chose the first because it was easier to implement; when the cost of building the table becomes a problem, the static array is the one to switch to.

5RP 4/12Pick another cell in the atlas

  1. Look up RP50V4C12
  2. Found: output a constant 0.39670.03210.1619
  3. Not found: search down for the row’s maximum chroma, report an error, return a black constant

    The maximum chroma is N!

Part of the material graph: the Munsell To RGB node, with (RP50, V4, C12) under its title and its output connected to the material’s Base Color.
The node connected to Base Color.
Stats panel: Base pass shader: 165 instructions.
The Stats panel in the same screenshot.

Chapter 3

The sRGB gamut boundary and a 40-page interactive atlas

A gamut is the range of colors a set of primaries can mix. As chroma rises, colors gradually exceed what sRGB can represent, and where they leave is different for each hue and each value. Of the 2734 colors in the Munsell renotation, 1109 (about four in ten) cannot be represented in sRGB because a channel goes negative, and were removed in RIT’s table; of the remaining 1625 cells, 1477 lie fully inside the gamut and another 148 have a channel above 1 that was clipped to 1.0. Recomputed from RIT’s chromaticity data, the color difference ΔE00 (the larger the number, the more visible the difference) of these 148 cells after clipping has a median of 2.6 and a maximum of 8.4 (at 7.5YR 9/8), and 144 of them are in the high-value layers V6 to V9. The node does no extra processing of its own and outputs what the table holds.

2734
Real colors in the Munsell renotation
1109
A channel below 0; the whole cell is dropped
148
A channel above 1; clipped to 1.0
V5
The chart slices through the color solid at one value: the 40 hues form a ring, with chroma increasing outward. Cells in the table are filled in with their color; the rest are left empty.

Value: how many cells each level has in the table; the darker part was clipped

  • In the table
  • Bold outer edge: a channel clipped to 1.0
  • 5RP: in Munsell, dropped from the table

Because the usable chroma limit is irregular for every hue and value, when a position outside the table is chosen it is better to state the boundary clearly at compile time than to silently return a color that is far off. In the 40-page interactive atlas below, click a cell in the table to see its 8-bit sRGB and the linear value the node actually outputs; click a dashed cell or a cross, and the panel on the right follows the logic of Compile(), searching downward for the highest chroma that exists in this row, raising the compile error The maximum chroma is N! and returning a black constant.

5RP

Red-Purple · page 38 of 40

Value
Chroma

5RP 4/12

sRGB (8-bit)16950112
Node output (linear)0.39670.03210.1619
  • In the table, 1477 cells
  • In the table, with a channel clipped to 1.0, 148 cells
  • 5RP: in Munsell but outside sRGB
  • Not in the table; click one to see how the node reports the error