The old WebGL renderer, with the transparent background code set as follows, is effective. But the web GPU renderer is invalid
const alpha = 0;
renderer.setClearColor(‘0xfffff’, alpha);
renderer.clear();
finalComposer.render();
alpha is set to true by default in WebGPURenderer so doing post processing with a transparent background works without further changes: https://jsfiddle.net/y5bqkv6w/
Do you mind updating the fiddle to clarify your issue?
Yes, is there any way to temporarily modify the method used in the Three.js source code locally? In addition, regarding whether to consider sharing and collaborating on online templates in the future using the codesandbox.io I shared earlier, it has a lot of better features, such as the ability to create new files on the left side, open a browser consistent debugging console below, better format code, and so on. JSFiddle cannot create new files on the left side. When there is a lot of code to share, it can only be written in one file, which makes it difficult to read.
You can download three.module.js locally and modify it to your hearts content.
(or just pull the whole package and edit the files you want…) and if you fix something, you’re then all set to make a PR.
r.e. codepen/et al… there is a lot of churn in those web sandboxes, and committing to one or another may require some substantial maintenance effort, which is energy better spent on maintaining the core library and reviewing PRs etc.
However, if you develop some useful solutions that address some of your pain points with the library, be sure to share them here so we can all benefit from your insights!
I downloaded the latest development branch code of Three.js and ran it locally. After fixing it with you, the background color under the glow background of WebGL and WebGPU is correct, which solves the PR I raised on GitHub. However, I tried the transparency issue on the forum and it did not solve it. I think you may have misunderstood the problem I raised in the community, or I may have raised a new PR on GitHub? When setting the div background color to blue, turning on post-processing glow, and setting clear alpha=0, the entire scene background should be blue
I think… with the postprocessing library, you are at the mercy of what the passes themselves do to alpha…
So my guess is the bloom pass has to use alpha to blend the output of the bloom convolution back with the original framebuffer… thus wiping out the alpha.
Additionally… the bloom itself won’t have an alpha associated with it, so if you do somehow manage to save/restore the alpha before/after the composer renders, the bloom won’t be visible outside the original outline of the objects in the buffer.
You might be able to modify the bloom pass to write the brightness of the bloom buffer to alpha during the composite with the original framebuffer?
It all sounds fiddly… but… if you can solve it… it might be worth a PR to bloompass.
If a post processing pass has to composite with the framebuffer, it has to output its own alpha value… (thereby destroying whatever alpha you wrote into the framebuffer).
But… you may be able to copy it off using some kind of hand written Pass, and then re-composite it as a final step in the post processing pipeline.
However… anything outside of that original alpha mask won’t render, including composer post process effects that may have rendered onto alpha!=1 regions.