LYGIA Shader Library

hue (lygia/v1.1.6/color/palette/hue)

Physical Hue.

Ratio: * 1/3 = neon * 1/4 = refracted * 1/5+ = approximate white

Use:

<vec3> hue(<float> hue[, <float> ratio])

Check it on Github


#ifndef FNC_PALETTE_HUE
#define FNC_PALETTE_HUE
vec3 hue(float x, float r) { 
    vec3 v = abs( mod(x + vec3(0.0,1.0,2.0) * r, 1.0) * 2.0 - 1.0); 
    return v*v*(3.0-2.0*v);
}
vec3 hue(float x) { return hue(x, 0.33333); }
#endif

Use:

<float3> hue(<float> hue[, <float> ratio])

Check it on Github


#ifndef FNC_PALETTE_HUE
#define FNC_PALETTE_HUE

float3 hue(float _hue, float _ratio) {
    return smoothstep(  
                        float3(0.0, 0.0, 0.0), float3(1.0, 1.0, 1.0), 
                        // float3(0.9059, 0.8745, 0.8745), float3(1.0, 1.0, 1.0),
                        abs( ((_hue + float3(0.0, 1.0, 2.0) * _ratio) % 1.0) * 2.0 - 1.0));
}

float3 hue(float _hue) { return hue(_hue, 0.33333); }

#endif

Dependencies:

Use:

<float3> hue(<float> hue[, <float> ratio])

Check it on Github



#ifndef FNC_PALETTE_HUE
#define FNC_PALETTE_HUE

inline __host__ __device__ float3 hue(float _hue, float _ratio) {
    return smoothstep(  make_float3(0.0f), make_float3(1.0f), 
                        abs( mod( _hue + make_float3(0.0f, 1.0f, 2.0f) * _ratio, 1.0f) * 2.0f - 1.0f));
}

inline __host__ __device__ float3 hue(float _hue) { return hue(_hue, 0.33333f); }

#endif

Examples

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository