Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

glsl-blend-soft-light

mattdesl34.2kMIT1.0.5

blend mode 'overlay' for GLSL

ecosystem:stackgl, blend, blend mode, mode, glsl, glslify, stackgl

readme

glsl-blend-soft-light

stable

(click for demo)

Photoshop-like "soft light" blend mode for GLSL.

#pragma glslify: blend = require(../)

void main() {
  vec4 bgColor = texture2D(bg, vUv);
  vec4 fgColor = texture2D(foreground, vUv);

  vec3 color = blend(bgColor.rgb, fgColor.rgb);
  gl_FragColor = vec4(color, 1.0);
}

Usage

NPM

blend(vec3 base, vec3 blend)

Blends background and foreground with an "soft light" blend mode. The algorithm for each channel is as follows:

(blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))

Contributing

See stackgl/contributing.

License

MIT. See LICENSE.md for details.