Skip to content

Bloom on transparent geometry#1848

Open
giagitom wants to merge 9 commits into
molstar:masterfrom
giagitom:bloom-on-transaprency
Open

Bloom on transparent geometry#1848
giagitom wants to merge 9 commits into
molstar:masterfrom
giagitom:bloom-on-transaprency

Conversation

@giagitom

@giagitom giagitom commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds bloom support for transparent and emissive geometry, and fixes bloom rendering on a transparent background.

image
  • Enable bloom on transparent/emissive geometry — emissive fragments are no longer discarded under transparency; they're scaled by alpha so semi-transparent surfaces emit, and the emissive pass is split into opaque and transparent (MAX-blended) renders.
  • Move bloom into the postprocessing/illumination pass — bloom is now owned by PostprocessingPass and composited inline in the postprocessing and illumination shaders, instead of as a separate trailing pass.
  • Enable bloom on transparent background — bloom is correctly applied and exported when the background is transparent.
  • Background-aware blend — screen on a transparent background (brightens without darkening), PMA-over on an opaque background (keeps the halo visible on bright backdrops), additive on geometry.
  • Tighten isBackground — use depth >= 0.99999994 ((2²⁴−1)/2²⁴) so the background test is precise for packed transparent depth.

Actions

  • Added description of changes to the [Unreleased] section of CHANGELOG.md
  • Updated headers of modified files
  • Added my name to package.json's contributors
  • (Optional but encouraged) Improved documentation in docs

giagitom and others added 2 commits June 7, 2026 23:22
- Move bloom into the postprocessing/illumination pass (composited inline)
- Tighten isBackground to handle packed transparent depth precisely
- Enable bloom on transparent background
- Background-aware blend: screen on transparent bg, PMA over on opaque bg, additive on geometry

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
compose.frag's isBackground still used `depth == 1.0`, so packed transparent
depth (~0.99999994 at background) was misclassified as geometry and bloom took
the additive branch instead of the background blend. Tighten it to match
postprocessing.frag and luminosity.frag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@giagitom giagitom requested a review from arose June 7, 2026 21:51

@arose arose left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like it, thanks!

There are some visual differences for emissive transparent geometry between standard and illumination mode. The emissive transparent geometry is less bright in illumination mode.

Emissive transparent geometry over a transparent background quickly (with higher emissiveness) losses any alpha so that the background is not visible anymore.

Are those intentional, want to change them?

@giagitom

Copy link
Copy Markdown
Collaborator Author

There are some visual differences for emissive transparent geometry between standard and illumination mode. The emissive transparent geometry is less bright in illumination mode.

Emissive transparent geometry over a transparent background quickly (with higher emissiveness) losses any alpha so that the background is not visible anymore.

Hi @arose, I missed that, thanks. It should be fixed now.

@arose

arose commented Jun 19, 2026

Copy link
Copy Markdown
Member

standard vs illumination still looks quite different with bloom on transparent objects. Without emissive, I don't see a difference.

Example opacity 0.3, emissive 0.5

image Standard image Illumination image Standard image Illumination

@giagitom

Copy link
Copy Markdown
Collaborator Author

@arose last commit should fix also this.

@arose

arose commented Jun 20, 2026

Copy link
Copy Markdown
Member

transparent bloom on white background looks odd

image

white bg

image

black bg

giagitom added 2 commits June 21, 2026 18:46
- Composite the premultiplied scene over the background (solid color or
  gradient/image/skybox environment) with premultiplied-over blending, so
  transparent objects keep full weight (SRC_ALPHA dimmed them to color*a^2)
  and bloom occludes the background instead of blowing out on light backgrounds
- Render premultiplied for solid background + bloom so the background composites
  last; unify solid and environment compositing into one premultiplied-over path
- Fix bloom composite uTexSizeInv (was texture size, not 1/size)
- Un-premultiply the opaque emissive bloom seed so fog no longer darkens halos
- Clamp bloom alpha so premultiplied-over never subtracts the background
@giagitom

Copy link
Copy Markdown
Collaborator Author

Now it should behave uniformly, and also fixed a few issues with environment enabled.

@arose

arose commented Jun 22, 2026

Copy link
Copy Markdown
Member

thanks!

transparent bg still does not look quite right. just adding a bit of emissive to a transparent surface makes it much more opaque

with opacity 0.5

image

emissive 0

image

emissive 0.3

@giagitom

Copy link
Copy Markdown
Collaborator Author

last commit should fix this

@giagitom

Copy link
Copy Markdown
Collaborator Author

it also reproduces the same results when exporting with tranparent bg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants