Transforming Colors

In this example, we’ll be adjusting the colors of an input texture. Ideally this would be done offline, but sometimes that’s either not convenient or there is a specific need to do it online as a part of a particular effect, for instance, driven by an expression or other parameters.




Given the example image, we want to adjust the redness or greenness of the image, without changing its lightness, or giving it an overall tint shift. We connect the output color to an asColorTransform node’s input. The input color is RGB and we will be outputting to CIELAB [1] color space, decomposing the output components. The first one is lightness, the second one is a* and the second one is b*.






The shading network shows the texture note RGB output connected to the asColorTransform , a remapValue node changing one of the components, and the round trip back to RGB via a second asColorTransform node.






Set the input to RGB and output to CIELAB color space. The a* component is responsible for the magenta/green opposition. A value of 0.5 is grey, lower values shift towards magenta, higher values shift towards green.

The same applies to the b* component, but this time it regard to the blue/yellow opposition instead.






Since we just want to adjust the intensity of the magentas and greens in the image, the Lightness and b are unchanged. We connect these to another asColorTransform node’s input components, and set its input mode to CIELAB and its output to RGB, then connect the a component to a standard Maya remapValue node’s input value







Leaving the position 0.5 with a value of 0.5 (greys unchanged, without a color shift), we apply a S like curve. This S like curve will increase the magentas and greens in a way similar to the S like tonal curves you are familiar with in image editing applications.








The S like curve used. Conversely, a flattening curve would bring the magent and greens towards the 0.5 values (the greys), flattening the colors.




If we wanted to do the same to the blues and yellows, we would be using the b* components of the CIELAB color space instead. One could also just want to increase the blueness of the image, or flatten the greens, or affect the lightness of the image only, leaving its colors unchanged.




Screenshots


Footnotes

[1]

CIELAB color space, https://en.wikipedia.org/wiki/Lab_color_space

Colorimetry - Part 4: CIE 1976 L*a*b* Colour Space pdf