mx_rgbtohsv
Converts a color from the machine-friendly RGB color space to the more human-intuitive HSV (Hue, Saturation, Value) color space.
Core Advantages
Enables independent and predictable control over a color's hue, saturation, and value, greatly simplifying artistic color adjustments and the implementation of effects based on color properties like brightness.
Common Uses
Individually adjusting H/S/V components in advanced color grading workflows.
Extracting the brightness (V component) of a color to use as a mask for effects.
Precisely identifying backgrounds in chroma keying by analyzing hue (H) and saturation (S).
How to adjust
This is a pure conversion function with no adjustable parameters. Its effect is understood through its input-output relationship: for example, any grayscale color input (e.g., vec3(0.8, 0.8, 0.8)) will yield an output with a saturation (y component) of 0 and a value (z component) equal to its gray level, 0.8, clearly separating the color's brightness from its chromaticity.
Code Examples
1// Convert RGB to HSV for manipulation
2const hsvColor = mx_rgbtohsv( originalRgbColor );
3
4// Increase saturation by 50%
5const adjustedHsv = vec3( hsvColor.x, hsvColor.y.mul( 1.5 ), hsvColor.z );
6
7// Convert back to RGB for display
8const finalRgbColor = mx_hsvtorgb( adjustedHsv );