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

alphaToCoverage not showing alpha #680

Closed
lambocorp opened this issue Feb 5, 2025 · 4 comments
Closed

alphaToCoverage not showing alpha #680

lambocorp opened this issue Feb 5, 2025 · 4 comments
Labels
support User support and general help

Comments

@lambocorp
Copy link

lambocorp commented Feb 5, 2025

When I attempt to use alphaToCoverage on a material, the pixels with alpha become all white.

https://codesandbox.io/p/sandbox/quirky-kalam-fnwnfw

Notably, renderer.antialias is false. Postprocessing docs say to initialize renderer this way.
And then use MSAA by EffectComposer.multisampling.
Threejs docs say that alphaToCoverage only works in MSAA enabled scenarios, so it should work here right? Even though their doc says to use antialias: true.

I expected the pixels to have transparency.

  • Three: [e.g. 0.171.0]
  • Post Processing: [6.36.6]

alphaToCoverage: Can only be used with MSAA-enabled contexts (meaning when the renderer was created with antialias parameter set to true).

@vanruesc
Copy link
Member

vanruesc commented Feb 5, 2025

This issue is unrelated to postprocessing. The white outlines around transparent edges appear when transparent is set to false. setting it to true fixes it. I'm not sure why this happens, but it also occurs without postprocessing.

A few notes regarding the example setup:

  • You're only using a single RenderPass
    • The EffectComposer automatically sets renderToScreen back to true when the pass is added because EffectComposer.autoRenderToScreen is true. However, setting that to false wouldn't help either, because then you'd get no ouput on the canvas.
    • Instead, you should use a final EffectPass or CopyPass to render the internal result to the canvas.
  • Using renderer.render() is exactly the same as using a single RenderPass that renders directly to screen.
    • Antialiasing doesn't work in this case because you're not rendering to a texture but to the canvas which has antialias set to false.

Here's a fixed demo: https://stackblitz.com/edit/postprocessing-v6-befqytyk?file=src%2FApp.js

@vanruesc vanruesc closed this as completed Feb 5, 2025
@vanruesc vanruesc added the support User support and general help label Feb 5, 2025
@lambocorp
Copy link
Author

The link added does not work.

Image

@vanruesc
Copy link
Member

vanruesc commented Feb 6, 2025

You're probably running into a browser configuration issue 🤔 https://developer.stackblitz.com/platform/webcontainers/browser-config

#works-on-my-machine

Image

@lambocorp
Copy link
Author

lambocorp commented Feb 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User support and general help
Projects
None yet
Development

No branches or pull requests

2 participants