How to avoid edge color bleeding when rendering on transparent background
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 280
- Forks
- 46
- Avg merge
- 10h 11m
- Merged PRs (30d)
- 2
Description
I wonder if there is a way to prevent the background color from bleeding into edge pixels when rendering objects on a fully transparent background (alpha=0). This happens when you calculate more than one sample per pixel for anti-aliasing. The following images show the effect, once for a black but transparent background (background=(0,0,0,0)) and once for a white transparent one (background=(1,1,1,0)).
To demonstrate the issue, I read the rendered RGBA image from the ANARI framebuffer to compose it on top of a checkerboard pattern using "source over" blending.
The following reference picture was created using my own OpenGL-based renderer, employing a simple supersampling technique to achieve anti-aliasing. It shows how the result should ideally look.
I would like to allow users of my application to render transparent graphics that are saved as a PNG file, e.g. to insert them later into a PowerPoint presentation. At the time of rendering, the user may not yet know whether the graphic will later be placed against a dark or a light background.
A possible workaround could be to render only 1 sample per pixel in VisRTX, but with a higher image resolution (true supersampling). The application can then downscale the final image, similar to what I did with the OpenGL image. However, it would be nicer if VisRTX directly supported a rendering mode that produces a clean image with smooth edges.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the ANARI framebuffer using multisample rendering and transparent backgrounds, then compare the composited output with the supplied OpenGL reference. The work is done when rendered transparent PNG edges no longer inherit the selected transparent background color and remain clean over different backgrounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100