lygia
/color
/blend
/screen
)Photoshop Screen blend mode mplementations sourced from this article on https://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/
Use:
blendScreen(<float|vec3> base, <float|vec3> blend [, <float> opacity])
#ifndef FNC_BLENDSCREEN
#define FNC_BLENDSCREEN
float blendScreen(in float base, in float blend) {
return 1. - ((1. - base) * (1. - blend));
}
vec3 blendScreen(in vec3 base, in vec3 blend) {
return vec3(blendScreen(base.r, blend.r),
blendScreen(base.g, blend.g),
blendScreen(base.b, blend.b));
}
vec3 blendScreen(in vec3 base, in vec3 blend, float opacity) {
return (blendScreen(base, blend) * opacity + base * (1. - opacity));
}
#endif
Use:
blendScreen(<float|float3> base, <float|float3> blend [, <float> opacity])
#ifndef FNC_BLENDSCREEN
#define FNC_BLENDSCREEN
float blendScreen(in float base, in float blend) {
return 1. - ((1. - base) * (1. - blend));
}
float3 blendScreen(in float3 base, in float3 blend) {
return float3( blendScreen(base.r, blend.r),
blendScreen(base.g, blend.g),
blendScreen(base.b, blend.b) );
}
float3 blendScreen(in float3 base, in float3 blend, float opacity) {
return (blendScreen(base, blend) * opacity + base * (1. - opacity));
}
#endif
Use:
blendScreen(<float|float3> base, <float|float3> blend [, <float> opacity])
#ifndef FNC_BLENDSCREEN
#define FNC_BLENDSCREEN
float blendScreen(float base, float blend) {
return 1. - ((1. - base) * (1. - blend));
}
float3 blendScreen(float3 base, float3 blend) {
return float3(blendScreen(base.r, blend.r),
blendScreen(base.g, blend.g),
blendScreen(base.b, blend.b));
}
float3 blendScreen(float3 base, float3 blend, float opacity) {
return (blendScreen(base, blend) * opacity + base * (1. - opacity));
}
#endif
Use:
blendScreen(<float|vec3> base, <float|vec3> blend [, <float> opacity])
fn blendScreen(base: f32, blend: f32) -> f32 {
return 1. - ((1. - base) * (1. - blend));
}
fn blendScreen3(base: vec3f, blend: vec3f) -> vec3f {
return vec3f(blendScreen(base.r, blend.r),
blendScreen(base.g, blend.g),
blendScreen(base.b, blend.b));
}
fn blendScreenWithOpacity3(base: vec3f, blend: vec3f, opacity: f32) -> vec3f {
return (blendScreen3(base, blend) * opacity + base * (1. - opacity));
}
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository