メインコンテンツまでスキップ

blendAdd: Additive Color Blending

Mathematical Foundation of Brightness Accumulation​

Additive blending increases image brightness by mathematically combining color values through addition. This operation simulates light emission where multiple light sources combine their intensities.

The mathematical definition is:

Cresult=min⁡(Cbase+Cblend,1.0)C_{result} = \min(C_{base} + C_{blend}, 1.0)

Where CbaseC_{base} is the background color, CblendC_{blend} is the overlay color, and the min⁡\min function prevents values from exceeding the maximum brightness threshold.

For opacity-controlled blending:

Cresult=blend(Cbase,Cblend)×α+Cbase×(1−α)C_{result} = \text{blend}(C_{base}, C_{blend}) \times \alpha + C_{base} \times (1 - \alpha)

Color Mathematics Properties​

PropertyDescriptionResult
IdentityAdding zero preserves original colorC+0=CC + 0 = C
CommutativityOrder independence in additionA+B=B+AA + B = B + A
Brightness IncreaseResult never darker than basebrightness(result)≥brightness(base)\text{brightness}(result) \geq \text{brightness}(base)
Clamping BehaviorValues saturate at maximum brightnessmax⁡(result)=1.0\max(result) = 1.0
ライブエディター

const fragment = () => {
      const center = vec2(0.5)
      const dist = uv.sub(center).length()
      const baseCircle = float(0.35).smoothstep(0.3, dist)
      const blendCircle = float(0.25).smoothstep(0.2, uv.sub(vec2(0.65, 0.4)).length())
      const base = vec3(0.2, 0.4, 0.8).mul(baseCircle)
      const blend = vec3(0.9, 0.3, 0.1).mul(blendCircle)
      const result = blendAddVec3(base, blend)
      return vec4(result, 1)
}
結果
Loading...