KSP-Conformal-Decals/Assets/ConformalDecals/Shaders/UI/HSL.cginc
Andrew Cassidy 7286202be9 Reorganize assets folder and tweak shaders
Moved rim shading and underwater fog to the common cginc
2024-07-25 23:29:42 -07:00

17 lines
427 B
HLSL

#ifndef HSL_INCLUDED
#define HSL_INCLUDED
inline float3 HSL2RGB(float3 hsl) {
int3 n = int3(0, 8, 4);
float3 k = (n + hsl.x * 12) % 12;
float a = hsl.y * min(hsl.z, 1 - hsl.z);
return hsl.z - a * max(-1, min(k - 3, min(9 - k, 1)));
}
inline float3 HSV2RGB(float3 hsv) {
int3 n = int3(5, 3, 1);
float3 k = (n + hsv.x * 6) % 6;
return hsv.z - hsv.z * hsv.y * max(0, min(1, min(k, 4 - k)));
}
#endif