Godot: Provide an option to use Alpha to Coverage (aka A2C) when MSAA is enabled

Created on 14 Mar 2018  路  9Comments  路  Source: godotengine/godot

The inclusion of this feature would effectively allow alpha-tested materials to appear anti-aliased. This is especially useful for foliage, and when used carefully, for hair. Considering how modern realtime hair is made, it's extremely difficult to avoid collisions and alpha sort correctly, and a two-pass system (rendering alpha-test first, rendering the remainder as alpha-sorted afterward) can introduce unwanted artifacts.

A robust A2C implementation effectively allows us to circumvent these issues and avoid the performance impact associated with alpha sorting multiple layers of geometry. While a quick, straightforward implementation would be wonderful, this article by Ben Golus notes some additional considerations that could elevate the usefulness of an implementation (namely 'sharpening' the result and preventing mipmaps from discarding useful details).

This is one of very few remaining obstacles to using state of the art character rendering techniques in Godot, not to mention improving other areas such as environment art. Given Godot's robust implementation of forward rendering, adding this technique to the native MSAA support should be achievable and provide additional motivation to utilize it.

archived feature proposal rendering

Most helpful comment

Here's an image of a basic character using a barebones implementation of the technique in the Blender Game Engine, including a zoomed version of the results at some distance so you can appreciate the subpixel variation. Keep in mind that, with a less orderly-looking alpha for the hair cards and the sharpening from the previous article, the difference in quality would be more apparent, so this isn't necessarily a perfect example of the benefits.

godota2crequest

All 9 comments

Here's an image of a basic character using a barebones implementation of the technique in the Blender Game Engine, including a zoomed version of the results at some distance so you can appreciate the subpixel variation. Keep in mind that, with a less orderly-looking alpha for the hair cards and the sharpening from the previous article, the difference in quality would be more apparent, so this isn't necessarily a perfect example of the benefits.

godota2crequest

Yes id love to see this! I believe it also helps with sorting issues vs traditional alpha?

@Gibbz Yes, as the article linked points out:

Okay, so with 4x MSAA and Alpha to Coverage you get 5 levels of opacity you can play with, 4/4 through 0/4 samples. What good is that? With traditional alpha blending you get at least 256 levels, so why would you ever want to use this? Because with Alpha to Coverage those coverage samples are opaque. That means they can be depth sorted! You can have a mesh of polygon soup and have intersecting triangles accurately sort at better than per pixel accuracy. This is no different than opaque objects or even alpha test with MSAA, but you also get soft edges.

Just keep in mind it's not designed to replace alpha blending in cases where you have transparency fading over a long distance. If you still need to use it in such cases, you could combine it with dithering (as seen in the GTA V Graphics Study).

Will this feature at least be considered for 4.0 (it's a rendering feature)? It would allow (a lot) prettier foliage. It would be nice to have at least the basic version of A2C described in the article ghost provided (im no expert in engine rendering, but the algorithm seems quite simple).
I'm asking because this issue looks lost, I can't find it through repository search, only through google.

@MilosLukic I believe antialiasing transparent materials can be achieved using the Opaque Pre-Pass material option:

image

This will use alpha blending only on alpha edges, which makes it possible to achieve smooth visuals while avoiding most alpha sorting issues.

That said, implementing alpha to coverage still makes sense if you wish to avoid alpha blending entirely.

@Calinou It can be, but transparent objects go to the transparent pipeline and causes all kinds of sorting issues (example in the article). Even with opaque pre-pass on. So avoiding the alpha blending completely gives us no issues with sorting, but allows pretty nice edges. The main issue is, that we have to have MSAA enabled for this. It's used by a lot of AAA games, but probably isn't very popular feature request due to lack of AAA games being developed in Godot.

Regarding use cases / motivation for this feature. On mobile tile-based graphics chips this is probably higher performance then blending and especially for mobile VR it is almost essential for good quality: https://developer.oculus.com/blog/common-rendering-mistakes-how-to-find-them-and-how-to-fix-them/

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Note that alpha to coverage is being implemented in https://github.com/godotengine/godot/pull/40364.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepProgger picture SleepProgger  路  3Comments

Spooner picture Spooner  路  3Comments

testman42 picture testman42  路  3Comments

kirilledelman picture kirilledelman  路  3Comments

blurymind picture blurymind  路  3Comments