# SSAO2 + skybox issue

**URL:** <https://forum.babylonjs.com/t/ssao2-skybox-issue/20441>\
**Category:** Feature requests\
**Tags:** pipeline\
**Created:** [April 29, 2021, 3:55pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441 "2021-04-29T15:55:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![JacobF](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jacobf/32/36046_2.png) [@JacobF](https://forum.babylonjs.com/u/JacobF)\
**Post date:** [April 29, 2021, 3:55pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/1 "2021-04-29T15:55:47Z")

</div>

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

 ![ảnh](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/84510e2c0bec4a92ca1f1b6b1c4eb1dc57548067.jpeg)

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`

Thoughts?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 29, 2021, 3:57pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/2 "2021-04-29T15:57:24Z")

</div>

Hey thanks a lot for your post!

Adding @CraigFeldspar and @julien-moreau

---

<div class="post-metadata">

**Author:** ![julien-moreau](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/julien-moreau/32/12070_2.png) [@julien-moreau](https://forum.babylonjs.com/u/julien-moreau)\
**Post date:** [April 29, 2021, 4:01pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/3 "2021-04-29T16:01:50Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![JacobF](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jacobf/32/36046_2.png) [@JacobF](https://forum.babylonjs.com/u/JacobF)\
**Post date:** [April 29, 2021, 4:11pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/4 "2021-04-29T16:11:15Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![JacobF](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jacobf/32/36046_2.png) [@JacobF](https://forum.babylonjs.com/u/JacobF)\
**Post date:** [April 30, 2021, 10:43pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/5 "2021-04-30T22:43:20Z")

</div>

Here is a PG of my setup [Babylon.js Playground](https://playground.babylonjs.com/#HW4X0M)

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

---

<div class="post-metadata">

**Author:** ![CraigFeldspar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/craigfeldspar/32/45631_2.png) [@CraigFeldspar](https://forum.babylonjs.com/u/CraigFeldspar)\
**Post date:** [May 1, 2021, 8:14am UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/6 "2021-05-01T08:14:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JacobF](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jacobf/32/36046_2.png) [@JacobF](https://forum.babylonjs.com/u/JacobF)\
**Post date:** [May 1, 2021, 2:32pm UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/7 "2021-05-01T14:32:48Z")

</div>

Great! Yes that works.

---

<div class="post-metadata">

**Author:** ![CraigFeldspar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/craigfeldspar/32/45631_2.png) [@CraigFeldspar](https://forum.babylonjs.com/u/CraigFeldspar)\
**Post date:** [May 7, 2021, 8:50am UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/8 "2021-05-07T08:50:51Z")

</div>

@JacobF here is the issue for tracking : [Have PrePassRenderer take `disableDepthWrite` flag into account · Issue #10338 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/issues/10338)

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [May 9, 2021, 10:34am UTC](https://forum.babylonjs.com/t/ssao2-skybox-issue/20441/9 "2021-05-09T10:34:22Z")

</div>

Nice. Appreciated 😃 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.
