question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposed: Order Independent Transparency

See original GitHub issue
Description of the problem

We (@Jozain and myself) are currently implementing out-of-order transparency for ThreeJS for a project of ours. We’d like to contribute it back. We are implementing the method of Morgan Mcguire, Weighted-Blended Order Independent Transparency: http://casual-effects.blogspot.ca/2014/03/weighted-blended-order-independent.html

We are helped a lot by @arose’s example OIT code on which our stuff will be partially based, just our stuff will be designed into the core of Three.JS: https://github.com/mrdoob/three.js/issues/4814

Here is an proposed example of how to enable this mode:

var renderer = new THREE.WebGLRendererer( .... );

// add new "transparency" variable to renderer to select the transparency rendering mode
//renderer.transparency = THREE.PaintersTransparency; // the current ThreeJS method, the painter's algorithm
renderer.transparency = THREE.OrderIndependentTransperancy; // the new OIT method

This mode will be implemented by a new WebGLOrderIndependentTransparency class that will be responsible for managing the buffers. It will create two additional RenderTargets that will track the size of the current render buffer. The first will be the accumulation buffer which we will render all transparency objects to and then we will render the objects as well to some alpha product buffers - thus two separate renders. This will be followed by a “resolve” stage that renders the transparent objects over top of the existing beauty render of the opaque objects.

This workflow will work with base WebGL and work with multi-sample buffers as well. It can obviously be speed up using multiple render targets, but this shouldn’t be that slow for non-huge numbers of transparent objects.

We are going to implement this now, just wanted to give a heads up as to our design so that if you have feedback on it, we can incorporate it now.

/ping @WestLangley @arose @spidersharma03

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:26
  • Comments:24 (19 by maintainers)

github_iconTop GitHub Comments

10reactions
bhoustoncommented, Jul 4, 2022

Myself and https://github.com/Threekit are pleased to put a bounty of $500 USD on an accepted PR of an implementation that supports order independent blending of transparent surfaces using the floating point buffer blending technique described in the original issue description above (or any further improved version.)

5reactions
stevinzcommented, Nov 1, 2022

I have implemented weighted, blended order independent transparency as a Pass that can be used as a stand-alone renderer, or in combination with other passes within an Effect Composer composition.

Github Repo - Online Example

This example builds on the progress made by @arose, @pailhead, and others.

Instead of monkey patching existing shaders (like 24227), the pass includes a material MeshWboitMaterial. This material is functionally equivalent to MeshBasicMaterial, with the addition of a weight property. This is implemented in the style presented in MeshGouraudMaterial.

This pass doesn’t need access to internal renderer framebuffers, and does not create a depth texture. In doing so it remains WebGL 1 compatible and mobile friendly (although, iPhone still doesn’t support writing to gl.FLOAT framebuffers and falls back to gl.UNSIGNED_BYTE which works, but doesn’t look as nice).

It is able to avoid creating a depth texture and the need to bind multiple render targets by re-using the depth buffer of the current writebuffer after each step. It also is able to generate it’s own list of opaque / transparent objects and render them separately by implementing a visibility cache (similar to OutlinePass).

I would be happy to submit a pull request to add this into the examples if this approach looks acceptable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Order-independent transparency - Wikipedia
Order -independent transparency (OIT) is a class of techniques in rasterisational computer graphics for rendering transparency in a 3D scene, ...
Read more >
Order independent transparency, part 1 - Interplay of Light
An alternative to modifying the content and draw order is to utilise an order independent transparency (OIT) rendering technique.
Read more >
Order Independent Transparency In OpenGL 4.x
Tail Handling: – Discard Fragments > K. – Blend below sorted and hope error is not obvious [Salvi et al.] ▫ Many close...
Read more >
Order Independent Transparency with Per-Pixel Linked Lists
In Section 2, we first survey the model of light transport in homogeneous transparent objects. Then, in Section 3 the new, GPU-based algorithm...
Read more >
WebGL 2 Example: Order-independent Transparency
WebGL 2 Example: Weighted, Blended Order-independent Transparency. Features: Vertex Arrays, Uniform Buffers, Immutable Textures, Multiple Render Targets, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found