deck.gl
deck.gl copied to clipboard
[Feat] Specify clearColor per view
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;
};
}
I prefer Option 2 for its brevity. This sounds like a great addition.
My vote:
- I prefer to avoid nested props for a few reasons, so option 1.
- Also we technically may not need the
clearflag 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
RenderPassdocs 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
trueorfalse. But that probably doesn't make sense for views as they all would need to follow the same depth buffer conventions.
I'm also fine with option 1.
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.