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
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
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