ECS layer compositor
README
ofxCompositorKit
FBO layer masks, nested bake groups, and SVG/CSS blend modes for the ofKitty stack.

CompositorSystem is a drop-in replacement for ofkitty::drawLayerContents(): it walks the same layer tree (layer_component roots, Relationship sibling order). Layers with a composite_pass_component render into an FBO and blit with ecs::BlendMode (SVG/CSS mix-blend-mode plus OF extras).Nested composite passes recurse (each pass begins/ends its own FBOs). Use
ecs::markCompositePassDirty(reg, entity) so ancestor passes rebuild when a child or mask changes.Usage
#include "ofxCompositorKit.h"
ofxCompositorKit::CompositorKit m_compositorKit;
void ofApp::setup() {
m_compositorKit.registerWith(ofkitty::runtime());
m_compositorKit.system().setCanvasSize(1000, 1000);
// Masked layer:
reg.emplace<ecs::composite_pass_component>(layerEntity,
ecs::composite_pass_component{
.maskSource = ecs::MaskSource::PathEntity,
.maskEntity = circleEntity,
.blendMode = ecs::BlendMode::Normal,
.dirty = true,
});
// Baked group (isolate children, Multiply onto parent):
reg.emplace<ecs::composite_pass_component>(groupEntity,
ecs::composite_pass_component{
.maskSource = ecs::MaskSource::None,
.blendMode = ecs::BlendMode::Multiply,
.dirty = true,
});
}
void ofApp::draw() {
ofkitty::runtime().drawSystems(); // canvas-phase systems
}registerWith() registers CompositorSystem with drawPhase = "canvas". Disable with system().setEnabled(false).Mask sources
MaskSource | Behaviour |
|---|---|
None | Bake children; blit color with blendMode only (layer group) |
PathEntity | maskEntity drawn alone; rendered alpha is the mask |
SubtreeAlpha | maskEntity + Relationship descendants; accumulated alpha |
PaintedFbo | maskEntity’s fbo_component (or valid fbo_reference) texture |
Keep path mask entities un-parented so the normal layer traversal neverdraws them. Give path masks a fill paint — geometry alone draws nothing.
Helpers in
LayerMaskOps.h: setPathLayerMask, clearLayerMask, hasPathLayerMask, findLayerForMask, markAllCompositePassesDirty.Editors that hide paths while editing can call
system().setSkipEntity(...) so color bake matches drawLayerContents.Blend modes
composite_pass_component::blendMode uses ecs::BlendMode. Blitting samples a backdrop copy of the current framebuffer so non-separable modes (Overlay, Hue, …) match Compositing and Blending Level 1.SVG / CSS
mix-blend-mode (16):| Enum | String |
|---|---|
Normal | normal |
Multiply | multiply |
Screen | screen |
Overlay | overlay |
Darken | darken |
Lighten | lighten |
ColorDodge | color-dodge |
ColorBurn | color-burn |
HardLight | hard-light |
SoftLight | soft-light |
Difference | difference |
Exclusion | exclusion |
Hue | hue |
Saturation | saturation |
Color | color |
Luminosity | luminosity |
| Enum | String |
|---|---|
Add | add |
Subtract | subtract |
Disabled | disabled |
ecs::blendModeToString / ecs::blendModeFromString
ofxAddons