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

Unable to implement Depth Peeling example without changing WebGLRenderer #19554

Closed
taphos opened this issue Jun 4, 2020 · 12 comments
Closed

Comments

@taphos
Copy link

taphos commented Jun 4, 2020

This is a continuation of #19305, which got stuck at some point

I would like to contribute an order independent transparency rendering example using Depth Peeling algorithm. Implementation requires to render transparent objects multiple times + one render of opaque objects. Current WebGLRenderer.setTransparentSort is not enough for that.
It would be nice to have an option to set whole custom WebGLRenderLists.

Additionally extendable WebGLRenderer would open alot of new opportunities, i.e. progressive rendering, custom backgrounds.. you name it.

Some stuff can be done by rendering multiple passes using EffectComposer instead, but it adds unwanted CPU overhead and increases code complexity. I suppose composer should be used for posteffects, not customizing rendering pipeline.

@pailhead
Copy link
Contributor

pailhead commented Jun 4, 2020

Is this related?

#15312

Not sure if there is much interest for OIT examples.

@taphos
Copy link
Author

taphos commented Jun 4, 2020

@pailhead 1 year old PR, damn. You made just a html example. I was thinking of something reusable, similar to postprocessing examples

@pailhead
Copy link
Contributor

pailhead commented Jun 4, 2020

I’m making that as well. Unfortunately I don’t know how to make it into a plug-in since it requires a one line core modification.

@pailhead
Copy link
Contributor

pailhead commented Jun 4, 2020

Also then possibly related:

#15490

@taphos
Copy link
Author

taphos commented Jun 4, 2020

@pailhead

requires a one line core modification.

Exactly. Thats what this ticket is about. Core requires a design change. OIT is just an example.

@pailhead
Copy link
Contributor

pailhead commented Jun 4, 2020

My stencil depth peel implementation has been cleaned up, i want to publish it as an npm module, but i'm not sure how to handle this discrepancy. It simply does not work the way three encapsulates that render buffer. Forking some version of three that only has this modification would make for one very weird dependency for such a package, and i'm not sure what effect would having that modified version live in the same package have.

I'm open to suggestions, i'm concerned that because it seems fairly useless to publish such a package, this implementation is not gaining any visibility, so both you and i in different parts of the world may end up implementing the same solution, none of which we're able to share with the world :(

@gkjohnson
Copy link
Collaborator

You should be able to use DepthTexture for this, no? Granted it won't work with some hardware but it's the only real way to write to a depth buffer and then read from it. If you need to change render target depth buffers in order to achieve the effect then #19447 is relevant, as well.

No one said explicitly but my hunch is that the proposed API change didn't fit into three.js' pattern for creating and managing webgl buffers. I was thinking that maybe depth buffers / textures should be set up and stored in properties independently of render targets so it can be checked if the last depth buffer is different than the current one and rebind it.

@taphos
Copy link
Author

taphos commented Jun 4, 2020

@gkjohnson @pailhead This ticket is about WebGLRenderer design, please create a new thread for depth peeling implementation discussion.

@pailhead
Copy link
Contributor

pailhead commented Jun 4, 2020

@taphos you should edit the title then not to mention some specific algorithm.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 6, 2022

Merging this into #9977. Also see #24903 which does not require changes to the core.

@Mugen87 Mugen87 closed this as completed Nov 6, 2022
@Mugen87 Mugen87 removed the Design label Nov 6, 2022
@gkjohnson
Copy link
Collaborator

Merging this into #19554.

@Mugen87 did you intend to link a different issue number? That is the same issue id as this one.

Also see #24903 which does not require changes to the core.

It would be great to see that merged as an example but alpha weighted blending has artifacts and visual oddities of its own and my feeling is that it's not a suitable replacement for something more robust and correct like depth peeling.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 29, 2022

Sorry, copy/paste error. Updated the post.

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

No branches or pull requests

4 participants