LYGIA Shader Library

levels (lygia/color/levels)

Combines inputRange, outputRange and gamma functions into one Adapted from Romain Dura (http://mouaif.wordpress.com/?p=94)

Dependencies:

Use:

levels(<vec3|vec4> color, <float|vec3> minInput, <float|vec3> gamma, <float|vec3 maxInput, <float|vec3 minOutput, <float|vec3 maxOutput)

Check it on Github



#ifndef FNC_LEVELS
#define FNC_LEVELS
vec3 levels(in vec3 v, in vec3 iMin, in vec3 g, in vec3 iMax, in vec3 oMin, in vec3 oMax) {
    return levelsOutputRange( levelsGamma( levelsInputRange(v, iMin, iMax), g), oMin, oMax);
}

vec3 levels(in vec3 v, in float iMin, in float g, in float iMax, in float oMin, in float oMax) {
    return levels(v, vec3(iMin), vec3(g), vec3(iMax), vec3(oMin), vec3(oMax));
}

vec4 levels(in vec4 v, in vec3 iMin, in vec3 g, in vec3 iMax, in vec3 oMin, in vec3 oMax) {
    return vec4(levels(v.rgb, iMin, g, iMax, oMin, oMax), v.a);
}

vec4 levels(in vec4 v, in float iMin, in float g, in float iMax, in float oMin, in float oMax) {
    return vec4(levels(v.rgb, iMin, g, iMax, oMin, oMax), v.a);
}
#endif

Dependencies:

Use:

levelsControl(<float3|float4> color, <float|float3> minInput, <float|float3> gamma, <float|float3 maxInput, <float|float3 minOutput, <float|float3 maxOutput)

Check it on Github



#ifndef FNC_LEVELSCONTROL
#define FNC_LEVELSCONTROL
float3 levelsControl(in float3 color, in float3 minInput, in float3 gamma, in float3 maxInput, in float3 minOutput, in float3 maxOutput) {
  return levelsOutputRange(levelsGamma(levelsInputRange(color, minInput, maxInput), gamma), minOutput, maxOutput);
}

float3 levelsControl(in float3 color, in float minInput, in float gamma, in float maxInput, in float minOutput, in float maxOutput) {
  return levelsControl(color, float3(minInput, minInput, minInput), float3(gamma, gamma, gamma), float3(maxInput, maxInput, maxInput), float3(minOutput, minOutput, minOutput), float3(maxOutput, maxOutput, maxOutput));
}

float4 levelsControl(in float4 color, in float3 minInput, in float3 gamma, in float3 maxInput, in float3 minOutput, in float3 maxOutput) {
  return float4(levelsControl(color.rgb, minInput, gamma, maxInput, minOutput, maxOutput), color.a);
}

float4 levelsControl(in float4 color, in float minInput, in float gamma, in float maxInput, in float minOutput, in float maxOutput) {
  return float4(levelsControl(color.rgb, minInput, gamma, maxInput, minOutput, maxOutput), color.a);
}
#endif

Dependencies:

Use:

levels(<float3|float4> color, <float|float3> minInput, <float|float3> gamma, <float|float3 maxInput, <float|float3 minOutput, <float|float3 maxOutput)

Check it on Github



#ifndef FNC_LEVELS
#define FNC_LEVELS
float3 levels(float3 v, float3 iMin, float3 g, float3 iMax, float3 oMin, float3 oMax) {
    return levelsOutputRange( levelsGamma( levelsInputRange(v, iMin, iMax), g), oMin, oMax);
}

float3 levels(float3 v, float iMin, float g, float iMax, float oMin, float oMax) {
    return levels(v, float3(iMin), float3(g), float3(iMax), float3(oMin), float3(oMax));
}

float4 levels(float4 v, float3 iMin, float3 g, float3 iMax, float3 oMin, float3 oMax) {
    return float4(levels(v.rgb, iMin, g, iMax, oMin, oMax), v.a);
}

float4 levels(float4 v, float iMin, float g, float iMax, float oMin, float oMax) {
    return float4(levels(v.rgb, iMin, g, iMax, oMin, oMax), v.a);
}
#endif

Licenses

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