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

Add alpha-to-coverage support (MSAA for alpha-tested materials) #1273

Closed
mindinsomnia opened this issue Jul 29, 2020 · 5 comments · Fixed by godotengine/godot#40364
Closed
Milestone

Comments

@mindinsomnia
Copy link

Describe the project you are working on:

A third person shooter.

Describe the problem or limitation you are having in your project:

Achieving a pleasant appearance for alpha transparent surfaces is very difficult due to limitations with Godot's rendering, due to the lack of antialiasing on alpha transparent surfaces with alpha scissor enabled, producing very harsh and noticeable visible aliasing on trees.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Alpha to Coverage, a technique for using MSAA on Alpha Scissor'd Surfaces to avoid hard aliasing artefacts around the edges of alpha scissor'd surfaces. When alpha scissor'd surfaces are drawn, individual MSAA samples are filled based on opacity, producing an antialiased edge along the alpha scissor surfaces with minimal performance overhead.

See this article for more information on what problems this feature solves and how it's implemented.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

I can't think of a reason why anyone with MSAA enabled would want to disable this feature once it is added, but if that is desired, then a simple tickbox under Godot's project settings would be sufficient, or it could be even a per-material or a shader option.

Beyond that, there would be no other differences in UX or functionality in Godot. The technical details on Alpha to Coverage are discussed in the article I previously linked.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

I can foresee myself using this in every 3D project I create in Godot, and certainly any time I create any kind of surface that relies on alpha transparency and alpha scissor. It could visually improve the quality of many types of assets. Eg: Trees, metal grates, wire fences, nets, floating text, etc.

I consider this a general quality improvement for Godot.

I do not see how this could be easily implemented with a script or shader code. At the very least, doing so is beyond my ability to do so.

Is there a reason why this should be core and not an add-on in the asset library?:

A basic rendering feature like this should be part of Godot, not a workaround or an add-on.

It would be likely very difficult to make this kind of additional feature an addon, difficult to maintain that addon, and an unnecessary burden for users to install that addon for this kind of basic rendering feature. Likewise an unnecessary burden for users to come up with some kind of workaround to this problem, assuming there is one.

The only workaround I can imagine is using actual mesh shapes instead of alpha scissor transparency, so for eg: individual leaves instead of alpha transparent images of tree branches, which would likely impact performance for scenes with a lot of foliage and require substantially more work.

It's a fairly standard feature which is found in most other modern game engines. This feature would likely be useful to basically everyone making a 3D game, given how common alpha transparent surfaces are in 3D graphics. Given this kind of feature should be relatively simple to implement for someone familiar with C++ experience and knowledge of how MSAA sampling works, and the huge benefits in visual quality to a broad number of games, I think it would be exceptionally worthwhile for Godot to have this as part of it's core.

@clayjohn
Copy link
Member

Its already implemented, just waiting for a merge godotengine/godot#40364 :)

@mindinsomnia
Copy link
Author

@clayjohn You just made my day! Thanks Clay!

@mindinsomnia
Copy link
Author

Since this is already coming, I'll close this request!

@Calinou
Copy link
Member

Calinou commented Jul 29, 2020

The proposal is still relevant until the PR is merged, so I'll reopen it.

@Calinou Calinou reopened this Jul 29, 2020
@Calinou Calinou changed the title Alpha to Coverage, MSAA Antialiasing for Alpha Scissored Surfaces Add alpha-to-coverage support (MSAA for alpha-tested materials) Jul 29, 2020
@mindinsomnia
Copy link
Author

Understood, thanks Calinou!

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

Successfully merging a pull request may close this issue.

4 participants