deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Feat] Specify clearColor per view

Open Pessimistress opened this issue 1 year ago • 9 comments

Target Use Case

As of v9.0, parameters.clearColor is no longer supported by Deck because WebGPU's clear color is per-render-pass and cannot be specified as a parameter. This change cost the ability to achieve certain color blending effects.

Proposal

Each View currently has an optional clear flag that defines the clear behavior. We could expand this to support finer-grained control over the clearing:

Option 1

type ViewProps = {
  ...
  clear?: boolean;
  /** @default [0, 0, 0, 0] */
  clearColor?: number[];
  /** @default true */
  clearDepth?: boolean;
}

Option 2

type ViewProps = {
  ...
  clear?: boolean | {
    /** @default [0, 0, 0, 0] */
    color?: number[];
    /** @default true */
    depth?: boolean;
  };
}

Pessimistress avatar Apr 25 '24 23:04 Pessimistress

I prefer Option 2 for its brevity. This sounds like a great addition.

chrisgervang avatar Apr 25 '24 23:04 chrisgervang

My vote:

  • I prefer to avoid nested props for a few reasons, so option 1.
  • Also we technically may not need the clear flag as omitting the color could be enough.

I am assuming that we do clear the framebuffer once before we start rendering the views, regardless of what the views state. I.e. the clear flags in the views are for controlling the composition of multiple views.

  • For reference, I updated the luma.gl RenderPass docs to reflect the current situation there, though changes to that API have been briefly discussed, so maybe we shouldn't try too hard to match it.
  • Notable is that the depthBuffer clear value can be specified, rather than just true or false. But that probably doesn't make sense for views as they all would need to follow the same depth buffer conventions.

ibgreen avatar Apr 26 '24 16:04 ibgreen

I'm also fine with option 1.

chrisgervang avatar Apr 26 '24 19:04 chrisgervang

FYI this will need to be in 9.1 because currently, we use a single render pass to draw all views. There are overlaps between LayersPassRenderOptions and the proposed view options (clearColor, clearCanvas). I suspect there will be some tricky corner cases in conflict resolution as we test the implementation.

Pessimistress avatar Apr 26 '24 21:04 Pessimistress