Skip to content

Make composite effects conform to the render and update contracts #74

Description

@jsulpis

Problem

CompositeEffectPass is typed as an EffectPass without fragment and vertex, so it promises the standard pass contract. Its implementation does not fulfill key parts of that contract:

  • The inherited API advertises render({ target, clear }), but composite render() accepts no options and ignores overrides.
  • onUpdated is typed as updates to the composite uniform object, but it forwards child-pass updates instead.
  • Direct writes to composite.uniforms do not use a reactive proxy and emit no update event.
  • Callback hooks use any despite the generic public type.

Impact

Consumers cannot write generic code over EffectPass | CompositeEffectPass safely. Render target overrides and clear behavior can fail silently, while render-on-demand code gets misleading update events. These inconsistencies will make nested composites and graph-level tooling difficult to add compatibly.

Relevant code

  • lib/src/passes/compositeEffectPass.ts:20-43,55-88
  • lib/src/passes/renderPass.ts:113-153,241-288

Proposed API decision

Create and export a shared render-options type:

type RenderOptions = {
  target?: RenderTarget | null;
  clear?: boolean;
};

Every renderable pass should implement render(options?: RenderOptions): void.

For composites:

  • Apply target to the final output child.
  • Define and document whether clear applies only to that child or to each child.
  • Make composite uniforms reactive, with onUpdated emitting only composite-uniform changes.
  • If child changes need to be observable, expose a separate explicitly typed callback that identifies the child pass.

Acceptance criteria

  • Composite render accepts and implements shared render options.
  • Target override and clear semantics are documented and tested.
  • onUpdated accurately represents composite uniform mutations.
  • Child-pass updates use a separate callback or are deliberately not exposed.
  • No public any is required for composite hooks.
  • A generic function accepting any renderable pass can call render(options) safely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions