lygia
/v1.1.4
/color
/levels
/inputRange
)Color input range adjustment similar to Levels adjusment tool in Photoshop Adapted from Romain Dura (http://mouaif.wordpress.com/?p=94)
Use:
levelsInputRange(<vec3|vec4> color, <float|vec3> minInput, <float|vec3> maxInput)
#ifndef FNC_LEVELSINPUTRANGE
#define FNC_LEVELSINPUTRANGE
vec3 levelsInputRange(in vec3 color, in vec3 minInput, in vec3 maxInput) {
return min(max(color - minInput, vec3(0.)) / (maxInput - minInput), vec3(1.));
}
vec4 levelsInputRange(in vec4 color, in vec3 minInput, in vec3 maxInput) {
return vec4(levelsInputRange(color.rgb, minInput, maxInput), color.a);
}
vec3 levelsInputRange(in vec3 color, in float minInput, in float maxInput) {
return levelsInputRange(color, vec3(minInput), vec3(maxInput));
}
vec4 levelsInputRange(in vec4 color, in float minInput, in float maxInput) {
return vec4(levelsInputRange(color.rgb, minInput, maxInput), color.a);
}
#endif
Use:
levelsInputRange(<float3|float4> color, <float|float3> minInput, <float|float3> maxInput)
#ifndef FNC_LEVELSINPUTRANGE
#define FNC_LEVELSINPUTRANGE
float3 levelsInputRange(in float3 color, in float3 minInput, in float3 maxInput) {
return min(max(color - minInput, float3(0., 0., 0.)) / (maxInput - minInput), float3(1., 1., 1.));
}
float4 levelsInputRange(in float4 color, in float3 minInput, in float3 maxInput) {
return float4(levelsInputRange(color.rgb, minInput, maxInput), color.a);
}
float3 levelsInputRange(in float3 color, in float minInput, in float maxInput) {
return levelsInputRange(color, float3(minInput, minInput, minInput), float3(maxInput, maxInput, maxInput));
}
float4 levelsInputRange(in float4 color, in float minInput, in float maxInput) {
return float4(levelsInputRange(color.rgb, minInput, maxInput), color.a);
}
#endif
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository