LYGIA Shader Library

saturation (lygia/color/blend/saturation)

Saturation Blend mode creates the result color by combining the hue and luminance of the base color with the saturation of the blend color.

Dependencies:

Use:

blendSaturation(<float|vec3> base, <float|vec3> blend [, <float> opacity])

Check it on Github



#ifndef FNC_BLENDSATURATION
#define FNC_BLENDSATURATION
vec3 blendSaturation(vec3 base, vec3 blend) {
  vec3 baseHSL = rgb2hsv(base);
  vec3 blendHSL = rgb2hsv(blend);
  return hsv2rgb(
      vec3(baseHSL.x, blendHSL.y, baseHSL.z));
}
vec3  blendSaturation(in vec3 base, in vec3 blend, float opacity) { 
    return (blendSaturation(base, blend) * opacity + base * (1. - opacity)); 
}
#endif

Dependencies:

Use:

blendSaturation(<float|float3> base, <float|float3> blend [, <float> opacity])

Check it on Github



#ifndef FNC_BLENDSATURATION
#define FNC_BLENDSATURATION
float3 blendSaturation(float3 base, float3 blend) {
  float3 baseHSL = rgb2hsv(base);
  float3 blendHSL = rgb2hsv(blend);
  return hsv2rgb(
      float3(baseHSL.x, blendHSL.y, baseHSL.z));
}
float3  blendSaturation(float3 base, float3 blend, float opacity) { 
    return (blendSaturation(base, blend) * opacity + base * (1. - opacity)); 
}
#endif

License

MIT License (MIT) Copyright (c) 2015 Jamie Owen

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