SSAO2 + skybox issue

I’ve been trying to find a solution for this (the sky is meant to be yellow):

Working with layerMasks is too complicated for my scene, to me it seems like the easiest solution is to be able to exclude meshes from the SSAO pass.

Another option might be to add observables before and after passes, then I would be able to make the mesh isVisible = false for that pass.

Edit: Another maybe simpler possibility would be to make SSAO2 respect disableDepthWrite = true


Hey thanks a lot for your post!

Adding @CraigFeldspar and @julien-moreau

Hey @JacobF
For the sky (using SkyMaterial or not), what I generally do is that I tag the material “disableDepthWrite = true”. In your case, do you need some passes to compute the sky except the final render of it ?

@julien-moreau that was the first thing I tried. It doesn’t have any effect in my scene for some reason. The skybox is just a normal cube with its own material.

Here is a PG of my setup Babylon.js Playground

Edit: Interestingly, when switching the PG to 4.2.0, disableDepthWrite magically starts working. Maybe there has been a regression?

Hi @JacobF,
Actually in 5.0 we use a more efficient way to render the depth texture, with the PrePassRenderer, and this seems to ignore the disableDepthWrite flag.
I’ll make a PR to fix that, in the meantime, you can fix your scene by setting the last SSAO2 parameter to true and forcing the old way of rendering depth :

const ssao = new BABYLON.SSAO2RenderingPipeline('ssao', scene, {
  ssaoRatio: .5,
  blurRatio: 1
}, [ camera ], true)

Hopefully this should be a quick fix so the PR should come very soon


Great! Yes that works.

1 Like

@JacobF here is the issue for tracking : Have PrePassRenderer take `disableDepthWrite` flag into account · Issue #10338 · BabylonJS/Babylon.js · GitHub


Nice. Appreciated :smiley: I ended up using SSAO instead in my scene demo #Project Snowball (late 2020), precisely because of this issue. Also, I’d say that depending on the use case, SSAO2 does not show a huge benefit over SSAO (at least, visually). My opinion only.