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
- 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)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
Recent Comments
- on Mesh Exploder (sources)
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
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