# SSAO bug with mirrored objects

**URL:** <https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349>\
**Category:** Bugs\
**Created:** [July 9, 2020, 1:46pm UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349 "2020-07-09T13:46:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kesshi](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kesshi](https://forum.babylonjs.com/u/Kesshi)\
**Post date:** [July 9, 2020, 1:46pm UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/1 "2020-07-09T13:46:03Z")

</div>

Hi, currently SSAO does not handle mirrored objects (negative scaling) correctly. You can see it here:  
[https://www.babylonjs-playground.com/#ZKC9KH](https://www.babylonjs-playground.com/#ZKC9KH)  
Is it possible to fix this? Our data model makes heavy use of morroring and currently we can’t use SSAO.

---

<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:** [July 9, 2020, 4:49pm UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/2 "2020-07-09T16:49:44Z")

</div>

pinging @CraigFeldspar who is currently working on our ssao2 implementation

---

<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:** [July 12, 2020, 8:10am UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/3 "2020-07-12T08:10:51Z")

</div>

It seems like this bug has been fixed by my last PR on SSAO.

When you force the old geometry buffer method (true to the last constructor parameter) :

```auto
        var tSSAO = new BABYLON.SSAO2RenderingPipeline("ssao", scene, {
                ssaoRatio: 0.5,
                blurRatio: 1.0,
            }, [camera], true);

```

we can indeed see the bug with the second cube.

Just use the latest version of babylon.js and you should be fine 🙂

---

<div class="post-metadata">

**Author:** ![Kesshi](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kesshi](https://forum.babylonjs.com/u/Kesshi)\
**Post date:** [July 13, 2020, 7:11am UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/4 "2020-07-13T07:11:31Z")

</div>

Thank you that works but the new method seems to have a bug with the background color.  
The color is brighter now.  
Compare these two links please:  
[https://www.babylonjs-playground.com/#ZKC9KH](https://www.babylonjs-playground.com/#ZKC9KH)  
[https://www.babylonjs-playground.com/#ZKC9KH#1](https://www.babylonjs-playground.com/#ZKC9KH#1)

---

<div class="post-metadata">

**Author:** ![Kesshi](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kesshi](https://forum.babylonjs.com/u/Kesshi)\
**Post date:** [July 17, 2020, 6:12am UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/5 "2020-07-17T06:12:05Z")

</div>

@CraigFeldspar Did you had time to look at the background color issue?

---

<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:** [July 17, 2020, 10:01am UTC](https://forum.babylonjs.com/t/ssao-bug-with-mirrored-objects/12349/6 "2020-07-17T10:01:16Z")

</div>

Hi @Kesshi,  
It seems it comes from the fact we use a post process to apply gamma color transform with this new ssao method.  
Fixing should be kinda easy though.  
In the meantime, you can apply a quick and dirty fix : apply gamma to linear space transformation to your background color : `scene.clearColor = scene.clearColor.toLinearSpace();`

Hope this helps,
