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

Order independent transparency #4814

Closed
arose opened this issue May 13, 2014 · 11 comments
Closed

Order independent transparency #4814

arose opened this issue May 13, 2014 · 11 comments

Comments

@arose
Copy link
Contributor

arose commented May 13, 2014

Recently @zz85 mentioned (#4724) a technique to render transparent objects without sorting. There is a paper and a blog post describing it. Also, it has been already implemented in webgl - in cesium (example).

I tried to implement the technique with three.js. Here is a demo and the code on github.

In the demo you can switch between the order independent rendering (oit), opaque or classical transparency requiring sorted rendering. It is quite convincing - until you start to zoom. I suspect it has something to do with how I calculate the z value for the accumulation and revelage shader. I'll try to figure that out, but any help is much appreciated!

@arose arose changed the title order independent transparency Order independent transparency May 13, 2014
@mrdoob
Copy link
Owner

mrdoob commented May 15, 2014

/ping @zz85?

@arose
Copy link
Contributor Author

arose commented May 15, 2014

I slightly changed the weighting function for the demo, i.e. lowered the orderingStrength (for the terminology see the presentation on the paper website) of the weight function. Maybe its a trade-of: more ordering discrimination results in a stronger effect when zooming. I guess in a setting where you (always) zoom/scale the whole scene it could make sense just apply the the rotation but not the scaling term of the modelViewMatrix.

Some more notes on my implementation. I used the approach with multiple render passes. The other approach is to use multiple render targets. Since the WEBGL_draw_buffers extension is now available in recent browsers it would be nice to have that too. However, as far as I know there is no api for multiple render targets in three.js so far. I guess this is a topic for another discussion.

@zz85
Copy link
Contributor

zz85 commented May 19, 2014

looks cool... i'll need to free up a bit of my brain cycles first before looking into this...

@navigator117
Copy link

in your demo code,

  1. the vertex shader, if the input is already premultipliedAlpha ( like transparent png output by PS), z = ( z4.xyz / z4.w ).z is not needed?
  2. your 2D compositingMaterial with Custom parameters:
    blending: THREE.CustomBlending,
    blendEquation: THREE.AddEquation,
    blendSrc: THREE.OneMinusSrcAlphaFactor,
    blendDst: THREE.SrcAlphaFactor
    the src & dst blend is invert compare to
    http://casual-effects.blogspot.com/2015/03/implemented-weighted-blended-order.html 2D Compositing Pass. why?

@looeee
Copy link
Collaborator

looeee commented Dec 6, 2018

Working live example: https://raw.githack.com/arose/three.js/oit/examples/webgl_oit.html

@trusktr
Copy link
Contributor

trusktr commented Jan 25, 2019

Looks like @pailhead has also made some progress on order-independent-transparency here: https://discourse.threejs.org/t/depth-peel-and-transparency/5365 (or is that something else? It seems to solve some issues that I've seen with the order-dependent transparency)

@pailhead
Copy link
Contributor

The demo doesnt run on ios :(

@pailhead
Copy link
Contributor

pailhead commented Jan 25, 2019

My approach unfortunately can’t work with three unless render buffers are somehow decoupled from targets. I’ve been thinking of somehow hijacking the gl state at the right time to maybe allow for that, but it seems very gnarly.

This approach might be more modern, it seems different than what I attempted.

@mrdoob
Copy link
Owner

mrdoob commented Jan 25, 2019

This approach might be more modern, it seems different than what I attempted.

How is it more modern?

@pailhead
Copy link
Contributor

I don't know need to dig into it, i figured it was written more recently since it does leverage shaders, the depth peel paper i worked off of i think predates shaders.

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 4, 2021

Merging into #9977.

@Mugen87 Mugen87 closed this as completed Mar 4, 2021
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

8 participants