Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Specify clearColor per view #8838

Open
Pessimistress opened this issue Apr 25, 2024 · 4 comments
Open

[Feat] Specify clearColor per view #8838

Pessimistress opened this issue Apr 25, 2024 · 4 comments
Labels
Milestone

Comments

@Pessimistress
Copy link
Collaborator

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;
  };
}
@chrisgervang
Copy link
Collaborator

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

@ibgreen
Copy link
Collaborator

ibgreen commented Apr 26, 2024

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.

@chrisgervang
Copy link
Collaborator

I'm also fine with option 1.

@Pessimistress Pessimistress added this to the v9.1 milestone Apr 26, 2024
@Pessimistress
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants