Open heyx3 opened 2 years ago
I decided to not do TAA, so Stochastic Transparency is a no-go. Instead we should investigate OIT techniques.
The first transparency solution will be basic: do a depth prepass for front-faces, a depth-prepass for back-faces, render back-faces (to get their depth, for fog calculations), then render front-faces.
Later, we should do OIT by utilizing Rasterizer-Ordered Views, an extension that lets you replace fixed-function operators like blending and depth-testing with programmable ones operating on image views. ROV's can give you fairly cheap OIT, including things like fog, as long as all triangles are sorted and rendered in one pass. This does NOT give you OIT between different transparent shaders rendered in different passes, so we will probably need to require that all transparent shaders use more or less the same material operations so they can be batched into a single draw call. We should be able to utilize bindless textures to let each layer reference their own textures.
It may be worth offering both the above forms of transparency, as two separate lighting models.
The OpenGL extension for ROV's is ARB_fragment_shader_interlock.
There are ways to render transparency without having to sort the surfaces, called "Order-Independent Transparency" or "OIT". You can use a blending equation that is commutative.
http://casual-effects.blogspot.com/2015/03/implemented-weighted-blended-order.html
One interesting wrinkle is that lighting and fog will likely have to be done in a forward pass.
Another option is "stochastic transparency", which renders transparent surfaces as opaque but randomly clips different pixels every frame, and relies on something like TXAA to smooth it out. This feels less "elegant" than OIT, but makes transparency effectively no different than opaque surfaces, renderable through the deferred pipeline. TXAA should also help for similar purposes in AO, volumetrics, so maybe this is the better way to go.