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

Option to disable two-pass rendering of transparent objects #24711

Closed
dmikis opened this issue Sep 29, 2022 · 12 comments · Fixed by #25165
Closed

Option to disable two-pass rendering of transparent objects #24711

dmikis opened this issue Sep 29, 2022 · 12 comments · Fixed by #25165

Comments

@dmikis
Copy link

dmikis commented Sep 29, 2022

Is your feature request related to a problem? Please describe.

There's a hardcoded path for rendering transparent objects with doublesided materials. However it's not particularly suitable for our use-case since our models are optimized for a single blended pass with backface fulling disabled. That leads to artifacts.

Describe the solution you'd like

An option for materials to override this behaviour.

Describe alternatives you've considered

Right now we're forced to patch by hand and commit into our repo a copy of threejs build.

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 29, 2022

Related #21967.

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 29, 2022

Since this feature request came up multiple times in the past, I'm inclined to support this request.

Finding a nice and compact property name might be difficult though since only double-sided, transparent materials are affected.

@dmikis
Copy link
Author

dmikis commented Sep 29, 2022

twoPassTransparentRendering? separateFrontAndBackSide? Both defaulting to true to preserve compatibility. I think a descriptive name would be better that a short one TBH :)

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 30, 2022

twoPassTransparentRendering sounds good to me. Would you be interested in making a PR?

@dmikis
Copy link
Author

dmikis commented Sep 30, 2022

Will do.

@WestLangley
Copy link
Collaborator

Adding this feature is up to @mrdoob.

But if it is added, I think it should be a property of the object, as is .renderOrder and .frustumCulled.

Double-sided, transparent, planar objects are a use case.

@dmikis
Copy link
Author

dmikis commented Sep 30, 2022

@WestLangley TBH I don't have any preference in the matter, I just want the option to exist and ready to submit a patch with any agreed upon solution (well, assuming, it won't take me a week to implement it :) ).

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 6, 2022

I'm okay with making this a property of Object3D. But let's leave #24719 open until @mrdoob tells his preference.

@dwoodruffsf
Copy link

I'd like to vote for this too. We are using the threejs runtime for the spine animation library, which exposes this problem. Spine uses 2-sided, transparent triangle batches, and it relies on those triangle batches being rendered in exactly the order they are submitted. But the winding-order of triangles in the list is heterogeneous (because it's driven by animations which can do funny things like scaling by -1). This creates artifacts where some parts of a character sort out of order.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 16, 2022

@mrdoob Given that the two-pass rendering introduces performance issues for certain users and an issue in context of gl_FrontFacing, I think we should make it optional. Are you okay with @WestLangley's suggestion in #24711 (comment) and introduce a new property for Object3D?

@mrdoob
Copy link
Owner

mrdoob commented Dec 21, 2022

How about adding a new material.side constant named THREE.TwoPassDoubleSide?

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 21, 2022

Sounds good to me, too! I'll give it a try.

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