Created
March 4, 2016 14:50
-
-
Save iUltimateLP/5129149bf82757b31542 to your computer and use it in GitHub Desktop.
A simple HLSL shader code to convert HSV to RGB colors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | |
float3 p = abs(frac(input.xxx + K.xyz) * 6.0 - K.www); | |
return input.z * lerp(K.xxx, clamp(p - K.xxx, 0.0, 1.0), input.y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clamp(..., 0.0, 1.0) can be replaced with saturate
It would also be nice to cite original source, if I'm not mistaken it's https://web.archive.org/web/20200207113336/http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl