home/ atoms/ hydra-blend-modes

Hydra's blend family composites two sources by arithmetic on their pixel colors

Blend functions take a second texture as their first argument and combine it with the current chain’s colors pixel-by-pixel, like Photoshop blend modes but running in real time on GPU framebuffers. The family: .blend(tex, amount) is a weighted average of the two (amount sets the mix, e.g. .blend(o1, 0.9)); .add(tex, amount) adds channels (clamped); .sub(tex, amount) subtracts; .mult(tex, amount) multiplies channels (like Photoshop Multiply); .diff(tex) takes the absolute color difference (inverting where textures match); .layer(tex) composites over using the incoming alpha; and .mask(tex) uses the incoming texture’s brightness as an opacity mask (bright = opaque, dark = transparent). The defining property — and the contrast with modulate — is that blending operates on color at the same coordinates, compositing two complete layers, whereas modulate warps geometry. Blending is therefore the primary tool for mixing two full visual layers into one image.

Examples

osc().blend(shape()).out()
osc().blend(o1, 0.9).out()       // 90% toward buffer o1
osc(10).rotate(0.5).diff(osc(200)).out()
osc(10).add(noise(), 0.5).out()
shape(3).diff(voronoi()).out()
osc().mult(gradient()).out()

Assessment

Explain in terms of pixel color values how .blend() differs from modulation. Predict the visual difference between .diff(osc(200)) and .mult(osc(200)) on the same base. State which blend function uses transparency for compositing, and build a patch that crossfades two sources by animating the blend amount.

“You can use _**blend**_ functions to combine multiple visual sources”
corpus · hydra-getting-started-official-interactive-tutorial · chunk 1
“The composite functions blend(), diff(), mult(), and add() perform arithmetic operations to combine the input texture color with the base texture color, similar to photoshop blend modes.”
corpus · hydra-livecoding-networked-visuals-source-repo · chunk 3
“The simple `blend` functions mixes the colors from two sources to create a third source.”