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
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- 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)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
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