mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
100.87k stars 35.23k forks source link

WebGPURenderer: global clipping planes applied to color space and tone mapping pass. #28838

Open aardgoose opened 3 weeks ago

aardgoose commented 3 weeks ago

Description

Now tone mapping and color space conversion are applied as a separate pass, the global clipping planes are applied to the rendered Quad.

I don't see a simple solution to this, and the problem will also apply to other post processing passes etc.

Q: Is attaching global clipping plains to the renderer the correct API. Should they be properties of the Scene, or be replaced with something like clipping groups.

@sunag @mrdoob @Mugen87 @RenaudRohlinger

Reproduction steps

  1. View the webgpu_clipping example.
  2. Enable global clipping

The canvas is vertically clipped with no connection to scene rotation.

Code

see example

Live example

Screenshots

No response

Version

166

Device

No response

Browser

No response

OS

No response

Mugen87 commented 3 weeks ago

The local per-material clipping does also not look correct when comparing with the WebGL example: https://threejs.org/examples/webgl_clipping

Is attaching global clipping plains to the renderer the correct API.

I would say no since the current API isn't suitable for multi-pass rendering. Moving the properties to the scene sounds like an obvious solution but having separate clipping groups could be a more clean approach. Do you already have in mind how a basic API would look like?

WestLangley commented 3 weeks ago

The canvas is vertically clipped with no connection to scene rotation.

In other words, to be consistent with WebGLRenderer, all clipping planes are defined in world space and clip in world space.

aardgoose commented 3 weeks ago

@WestLangley

The global clipping is applied twice, once correctly in the scene world space, and again on the built in post processing pass effectively in screen space.

@Mugen87

I implemented ClippingGroups in #28237 (before this problem existed, so it wasn't intended as a fix). Issues around handling intersection vs union clipping planes interact would need to be worked out, and even if clipping planes should be associated with materials.

Mugen87 commented 3 weeks ago

Sorry I have overlooked https://github.com/mrdoob/three.js/pull/28237. After looking at the API and how it affects the example code I really like this kind of clipping concept. I guess more than material or renderer properties.

I would suggest to revisit https://github.com/mrdoob/three.js/pull/28237 and see it as a replacement for the former API that I would not support in WebGPURenderer. We have the chance now to adapt new, better concepts in the renderer and clipping groups sound interesting.