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

Add Flag to Disable Rendering Object in Transmission Pass #29592

Open
joarfish opened this issue Oct 8, 2024 · 0 comments
Open

Add Flag to Disable Rendering Object in Transmission Pass #29592

joarfish opened this issue Oct 8, 2024 · 0 comments

Comments

@joarfish
Copy link

joarfish commented Oct 8, 2024

Description

We render an object with the MeshPhysicalMaterial with transmission set to 1. We allow users to apply clipping planes to that object. Because we want to render the "inside" of the object, we set the side to DoubleSide. However, we also want to render the object with a specific color.

Displaying the object with a certain color is tricky with this configuration though, because when side is set to DoubleSide the object will be rendered in the transmission pass with side set to BackSide and consequently transmit through itself, as it were. This is often desirable, I guess, but in our case it will distort the color in a way we do not want. We want to use double side rendering just to show the backsides of the object when clipping is applied.

Rendered with FrontSide:
transmission_issue_w_front-side
Rendered with DoubleSide:
transmission_issue_w_double-side

You can also see the effect here: https://codesandbox.io/p/sandbox/2jpp8k (Modify line 32 to switch between front side and double side rendering)

An entry to the relevant code can be found here: https:/mrdoob/three.js/blob/dev/src/renderers/WebGLRenderer.js#L1542

Solution

Introduce a local (material-level) or a global flag to control whether objects with transmission !== 0 and side === DoubleSide will be rendered in the transmission pass. The current behavior could be preserved by setting the flag to true by default.

If it is agreed upon that this is a desirable feature, I'd be willing to contribute a PR.

Alternatives

We can work around the problem by setting the drawRange.count to 0 via the onBeforeRender for just the transmission pass, effectively hiding the object. This, however, has the shortcoming of still issuing a draw call during the transmission pass for the object.

Additional context

No response

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

No branches or pull requests

2 participants