Skip to content

feat: Improve selective bloom to use mipmap blur - #832

Open
Otokami-Orokabu wants to merge 5 commits into
maplibre:mainfrom
Otokami-Orokabu:feat/selective-bloom-mipmap-blur
Open

Otokami-Orokabu wants to merge 5 commits into
maplibre:mainfrom
Otokami-Orokabu:feat/selective-bloom-mipmap-blur

Conversation

@Otokami-Orokabu

Copy link
Copy Markdown
Collaborator

Overview

The bloom blur was a fork of three.js UnrealBloomPass, which upsamples its mips bilinearly. Spread wide, the lowest mip shows through as square halos, and the hard threshold makes emitters near it flicker. This swaps the blur for postprocessing's MipmapBlurPass (already a dependency).

Closes #

What I've done

  • SelectiveBloomEffectDesc blurs with MipmapBlurPass; threshold moved to the extract pass, strength to the composite. UnrealBloomPassRGBA removed.
  • Added smoothing and levels. radius is now the upsample blend ratio (0-1, default 0.85, was 0.2).
  • The composite adds the unblurred source back (base + strength × (source + blur)) so emitters still read as self-lit.
  • Docs (en/ja) updated, bloom example screenshots regenerated, smoothing / levels added to /debug-selective-effect.
  • fix(example): instanced-mesh sets useNormal: true (tiles went unlit after feat: Support hillshade(DEM-based Normal) #474) and the polyline demo gets a maxWidth. refactor(example): inert flags removed.

BREAKING CHANGE: radius changed meaning and default, UnrealBloomPassRGBA is gone, and the blur no longer amplifies energy (~3x), so raise strength 2-3x for the previous brightness.

What I haven't done

  • No unit tests (effect passes have none and need a GL context); verified with screenshots and frame timing.
  • Mask extraction still runs at resolutionScale, so thin shapes can get jagged edges.

How I tested

  • cargo make build-example / format / lint / test pass.
  • /selective-bloom-effect-* and /effect/selective-bloom compared against the previous implementation.

Screenshots

Before After
before after

Checklist

  • Wrote a clear PR description so reviewers can quickly understand the overview of the changes.
  • Confirmed that the proposed code does not include anything with an unknown or incompatible license.
  • Added tests for the changes.
  • Updated the API documentation.
  • Linked related issues.

UnrealBloom's bilinear mip sum shows square halos when spread wide; a
mipmap down/upsample chain blurs smoothly. Adds smoothing and levels, and
re-adds the unblurred source in the composite so emitters read as self-lit.

BREAKING CHANGE: radius is now the upsample blend ratio (0-1, default 0.85,
was 0.2). The blur no longer amplifies energy (~3x), so raise strength 2-3x
to keep the previous brightness. UnrealBloomPassRGBA is removed.
The useNormal default flip (maplibre#474) left the OSM tiles unlit, so the demo's
exposure of 3 overexposed the map. The 1,500 km polyline was clamped to
sub-pixel by the default maxWidth.
transparent with opacity 1 sent opaque meshes down the blended path, and
castShadow without shadow: true, hideUnderground: false and the unused
width param had no effect. Layer order aligned to terrain, hillshade, raster.
Copilot AI lite review requested due to automatic review settings September 18, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical and moderate review findings remain unresolved, including mip-chain resizing and delta-time handling.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR replaces the custom Unreal bloom blur with MipmapBlurPass, adding configurable smoothing and mip levels while updating examples and documentation.

Changes:

  • Reworked bloom extraction, mipmap blurring, and compositing.
  • Added smoothing and levels configuration and debug controls.
  • Updated examples and documentation; removed UnrealBloomPassRGBA.
File summaries
File Review summary
web/navara_three/example/pages/selective-bloom-effect/mvt-point/main.ts Adjusted bloom strength and layers.
web/navara_three/example/pages/selective-bloom-effect/mesh/main.ts Removed transparent material flags.
web/navara_three/example/pages/selective-bloom-effect/instanced-mesh/main.ts Enabled normals and adjusted shadow flags. Two moderate findings remain (2 votes each) concerning functional building and terrain shadow options.
web/navara_three/example/pages/selective-bloom-effect/geojson-polyline/main.ts Adjusted layers and polyline width.
web/navara_three/example/pages/selective-bloom-effect/geojson-point/main.ts Adjusted bloom strength.
web/navara_three/example/pages/selective-bloom-effect/geojson-large-draped-polygon/main.ts Adjusted layers and globe settings. One moderate finding remains (2 votes) concerning hideUnderground behavior.
web/navara_three/example/pages/selective-bloom-effect/feature/main.ts Adjusted bloom strength.
web/navara_three/example/pages/debug/selective-effect/run.ts Added smoothing and mip-level controls.
web/navara_three_default_descs/src/effects/UnrealBloomPassRGBA.ts Removed obsolete bloom pass.
web/navara_three_default_descs/src/effects/SelectiveBloomEffectDesc.ts Implements the new pipeline. Findings remain for smoothing edge handling (moderate, 3 votes), mip-chain rebuilding (critical, 2 votes), level validation (moderate, 1 vote), and delta-time handling (critical, 1 vote).
docs/src/content/docs/three_default_descs/Effect Desc/selective-bloom-effect-desc.md Updated English documentation. One nit remains (2 votes) regarding emissive intensity behavior and its tuning formula.
docs/src/content/docs/ja/three_default_descs/Effect Desc/selective-bloom-effect-desc.md Updated Japanese documentation. One nit remains (2 votes) regarding emissive intensity behavior and its tuning formula.
Review details

Suppressed comments (1)

web/navara_three_default_descs/src/effects/SelectiveBloomEffectDesc.ts:32

  • The public levels option is passed straight to MipmapBlurPass.levels, but unlike the debug control it accepts zero, negative, or fractional values. Those values do not describe a valid mip chain and can result in missing targets or invalid loop bounds; validate or normalize it to a positive integer before assigning it.
  levels?: number;
  • Files reviewed: 12/24 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread web/navara_three_default_descs/src/effects/SelectiveBloomEffectDesc.ts Outdated
@keiya01 keiya01 changed the title Feat/selective bloom mipmap blur feat: Improve selective bloom to use mipmap blur Sep 18, 2026
smoothstep is undefined for equal edges, so smoothing 0 now falls back to
step(). levels is rounded and clamped to at least 1 before it reaches
MipmapBlurPass, which has no targets to sample at 0.
Copilot AI review requested due to automatic review settings September 18, 2026 08:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Copilot reviewed 12 out of 24 changed files in this pull request and generated 4 comments.

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