Skip to content

feat: add screen-space ambient occlusion (SSAO)#993

Open
hubbardp wants to merge 2 commits into
google:masterfrom
hubbardp:ssao
Open

feat: add screen-space ambient occlusion (SSAO)#993
hubbardp wants to merge 2 commits into
google:masterfrom
hubbardp:ssao

Conversation

@hubbardp
Copy link
Copy Markdown
Contributor

Summary

Screen-space ambient occlusion (SSAO) simulates shadows on 3D mesh surfaces by darkening crevices and concavities where ambient light would be occluded. It adds depth cues that help us perceive shapes, and it makes the display more appealing. SSAO is an efficient post-processing effect applied to the perspective view after opaque geometry is drawn. See src/ssao/README.md for more details and example images.

Screenshots

ssao-off ssao-on

Usage

  • Press q to toggle SSAO on and off.
  • Use sliders in the "Settings" panel to adjust intensity and radius (softness).

Known limitations

  • SSAO is disabled in any perspective view that contains a volume-rendering layer; a one-time status banner notifies the user.
  • Translucent annotations covering a mesh suppress SSAO at the covered pixels.

Performance

  • The first use of SSAO triggers the creation of the NORMAL attachment, retained thereafter.
  • The first use of SSAO triggers mesh shader recompilation.
  • All uses of SSAO add three additional full-screen passes.
  • No user-perceptible change in performance, even when tested on older laptops with only integrated graphics.

Algorithm

GTAO (Ground Truth Ambient Occlusion): Jimenez et al., "Realtime Strategies for Accurate Indirect Occlusion", SIGGRAPH 2016

Testing

  • Manually verified with various datasets from Janelia, OpenOrganelle.
  • New browser tests in src/ssao/shaders.browser_test.ts cover composite math, GTAO and composite sentinel paths, blurring pass.

@chrisj
Copy link
Copy Markdown
Contributor

chrisj commented May 15, 2026

@hubbardp this is very exciting! Looks great from a quick look so far

flyem_fib-25 DEMO

Comment thread src/ssao/shaders.ts
// World→UV scale: wClip is -P.z under perspective and 1 under ortho.
float wClip = uProjection[2][3] * P.z + uProjection[3][3];
float screenRadius = uRadius * uProjection[1][1] / (2.0 * wClip);
screenRadius = min(screenRadius, MAX_KERNEL_FRACTION);
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.

In the link I posted, I can't see any visible difference when changing the radius value, I'm wondering if the value is always larger than MAX_KERNEL_FRACTION

@hubbardp
Copy link
Copy Markdown
Contributor Author

For those who want to try the new functionality without building the code, it's running here:
http://neuroglancer-ssao.janelia.org/

@chrisj
Copy link
Copy Markdown
Contributor

chrisj commented May 15, 2026

@hubbardp neuroglancer github actions are set up to create a deployment for every PR, available if you click "view details", it's definitely not obvious:
Screenshot 2026-05-15 at 12 48 12 PM
That's what I used to create the link I posted.

@jbms
Copy link
Copy Markdown
Collaborator

jbms commented May 15, 2026

What is the reason for disabling the effect on highlighted segments? It makes the highlighting rather jarring, though I haven't tested with the alternative behavior.

@hubbardp
Copy link
Copy Markdown
Contributor Author

What is the reason for disabling the effect on highlighted segments? It makes the highlighting rather jarring, though I haven't tested with the alternative behavior.

I tried not disabling the SSAO darkening on highlighted segments, and they were too dark to see when highlighted. Personally, I like the brighter highlighting. I found that before SSAO, sometimes the randomly-chosen segment color was bright enough that the highlighting seemed barely distinguishable.

@fcollman
Copy link
Copy Markdown
Contributor

this look really cool! i'm excited by it.

I immediately went to a very busy microns dataset to see what it would look like

link

and I see thing looks reasonable when viewed from the +/-xz, +/-yz view, but rotating it +/- xy everything looks dim and muddy.

YZ looks good here
image

XY all the cells in the middle look dulled, when i was expecting some to look brighter.
image

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.

4 participants