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

Fixed sprite transparency artifacts #2428

Closed
wants to merge 1 commit into from
Closed

Fixed sprite transparency artifacts #2428

wants to merge 1 commit into from

Conversation

TheArchitect4855
Copy link

Objective

Solution

  • Fragments with an alpha value below 0.5 are now discarded (transparent cutout).

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Jul 3, 2021
@@ -20,5 +20,7 @@ void main() {
sampler2D(ColorMaterial_texture, ColorMaterial_texture_sampler),
v_Uv);
# endif
if(color.a < 0.5) discard;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I read somewhere that discard hurts performance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hardware dependent (source). In any case, the performance hit shouldn't be noticeable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a cutout value of 0.5? Isn't that high?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the "standard" default value from my experience. I'm looking into making it customisable, but we'll see if time permits.

@NathanSWard NathanSWard added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jul 3, 2021
@CptPotato
Copy link
Contributor

I think this is a good solution for sprites where 1 bit alpha is desired, as this allows them to use the shading path for opaque geometry.
Sprites that are meant to be transparent and shaded as such would need a separate solution however.

@mockersf mockersf added the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Jul 16, 2021
@alice-i-cecile
Copy link
Member

@TheArchitect4855 could you please comment in #2373 :) I'm tackling the backlog, and this PR is from before then.

@mockersf mockersf removed the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Apr 23, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering artifacts with overlapping transparent sprites
6 participants