Oct
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

 


4 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch Instagram

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.