Skip to main content

blendOverlay: Conditional Multiply-Screen Blend

Mathematical Foundation of Overlay

Overlay blending creates natural color enhancement by conditionally applying multiply or screen blending based on the base color value. This creates realistic shadow and highlight behavior that responds to the underlying image tones.

The mathematical definition is:

Cresult={2CbaseCblendif Cbase<0.512(1Cbase)(1Cblend)otherwiseC_{result} = \begin{cases} 2 \cdot C_{base} \cdot C_{blend} & \text{if } C_{base} < 0.5 \\ 1 - 2(1 - C_{base})(1 - C_{blend}) & \text{otherwise} \end{cases}

The 50% threshold creates a natural division where dark areas are multiplied (creating shadows) and bright areas are screened (creating highlights).

Conditional Enhancement Properties

Base ValueApplied ModeEffectMathematical Result
Dark (< 0.5)Multiply × 2Shadow enhancementDarkening
Bright (≥ 0.5)Screen modeHighlight enhancementBrightening
50% GrayTransition pointNatural boundarySmooth blend
Neutral BlendPreserves baseNo dramatic changeNatural enhancement
Live Editor
const fragment = () => {
      const gradient = vec3(uv.x)
      const base = gradient
      const pattern = float(0.5).step(uv.y.mul(10).fract())
      const blend = vec3(pattern.mul(0.3).add(0.4))
      const result = blendOverlayVec3(base, blend)
      return vec4(result, 1)
}