19
2018
HSV Debugging and Color Match Shader
Quick test for color matching using shader,
by converting colors into HSV and comparing target color with h-s-v threshold values.
See Shader source at the bottom.

(main image: Changing target color, shows inverted color for the texture in that matching hue position)
Shader has different draw modes for debugging:

for RemapHue, need to supply this texture in “HueGradientTexture” field
![]()
Here is my testing texture

One question remains:
Why do i need to invert targetHue for the hueDistance calculation? (otherwise it picks wrong hue..)
float hueDist = abs(sourceHSV.x – (1-targetHSV.x));
References:
– RGB to HSV http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
Shader source:
– https://github.com/UnityCommunity/UnityLibrary/blob/master/Assets/Shaders/2D/Debug/HSVDebugger.shader
Related Posts
4 Comments + Add Comment
Leave a comment
Recent posts
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
Recent Comments
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by












Full HSV to RGB conversion, RGB to HSV conversion
https://www.ronja-tutorials.com/2019/04/16/hsv-colorspace.html
HSV Standard Shader
https://forum.unity.com/threads/adding-hue-saturation-and-contrast-to-standardshader.843697/#post-5572063
Utility functions to convert between various color spaces in GLSL (RGB,sRGB,XYZ,xyY,HCV,HUE,HSV,HSL,HCY,YCbCr)
https://github.com/tobspr/GLSL-Color-Spaces
Shader to adjust: Hue Brightness Contrast Saturation
https://forum.unity.com/threads/hue-saturation-brightness-contrast-shader.260649/#post-4693943