-
-
Notifications
You must be signed in to change notification settings - Fork 170
wg_engine: alpha premultiplied bug fix #4066
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an alpha premultiplication bug in the WebGPU rendering engine by introducing a new sampler specifically configured for image rendering. The fix addresses issue #4041 where images were being rendered with incorrect alpha blending due to using a generic linear clamp sampler instead of a properly configured image sampler.
Key Changes:
- Added a new
samplerImageswith different min/mag filter settings optimized for image rendering - Updated
WgImageDatato use the new image-specific sampler instead of the generic linear clamp sampler - Introduced a new overloaded
createSamplermethod to support different min/mag filter configurations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tvgWgRenderData.cpp | Updates bind group creation to use the new samplerImages instead of samplerLinearClamp |
| tvgWgCommon.h | Declares the new samplerImages member and overloaded createSampler method |
| tvgWgCommon.cpp | Implements initialization, cleanup, and creation logic for the new image sampler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
96529cc to
9777920
Compare
Fix sampler setings for un-premultiplied images #4041
9777920 to
dffcc08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@SergeyLebedkin Please test on the thorvg viewer. Thanks. |
|
Hi @SergeyLebedkin, Thank you for the PR. I tested it and noticed a regression when scaling the image to 4×. To address this, I’d like to suggest pre-multiplying the alpha channel before storing the image into the drawing texture. Would you be open to handling this step with GPGPU via WebGPU in the PR? I think doing the premultiply as a lightweight compute pass (or equivalent) could keep the cost low and avoid CPU-side preprocessing. Thanks again for taking a look. |
Fix sampler setings for un-premultiplied images by updating sampler for images
#4041