jamieowen / glsl-blend

glsl photoshop blending modes. glslify formatted.
MIT License
1.04k stars 121 forks source link

Subtract mode error #12

Open xiaozhuai opened 2 years ago

xiaozhuai commented 2 years ago

Subtract is not as same as LinearBurn

Subtract should be

float blendSubtract(float base, float blend) {
    return max(base-blend, 0.0);
}

vec3 blendSubtract(vec3 base, vec3 blend) {
    return max(base-blend, vec3(0.0));
}

vec3 blendSubtract(vec3 base, vec3 blend, float opacity) {
    return (blendSubtract(base, blend) * opacity + base * (1.0 - opacity));
}