meshcat-dev / meshcat

Remotely-controllable 3D viewer, built on top of three.js
MIT License
250 stars 44 forks source link

Notes on enabling ambient occlusion with EffectComposer #113

Open gizatt opened 2 years ago

gizatt commented 2 years ago

I spent a little while playing with adding postprocessing using EffectComposer, which requires relatively few additional LOC (branch here) to support. It works OK:

Without: Selection_034 With: Selection_035

Note that it's adding darkening inside of the cabinet at the creases. I don't love either Meshcat SSAO implementations (or I haven't tuned them very well yet; they all create really bad halos), but a subtle application does help readability on solid-color boxy geometry. It's really easy to add in more postprocessing stages (see the threejs examples) using the same pipeline.

I hit one weird glitch: there's a weird ghosting that only shows up only when the gradient background is enabled. Here's a picture of it (with extremely-high-amplitude SAO applied): Selection_037

And here's the normal map used by the SAO pipeline: Selection_036

My first instinct is that the texture being used by the gradient background is causing some side-effect geometry that's being picked up by the postprocessing shader internals; there are a couple of threejs issues (like this one that give me a sense that threejs bugs might be the culprit. Either way, this'll need more work before it could be made a feature.