# SSAO2 does not behave correctly with dynamically changing camera parameters

**URL:** <https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245>\
**Category:** Bugs\
**Tags:** post-process, ssao2\
**Created:** [November 2, 2025, 7:10am UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245 "2025-11-02T07:10:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![noname0310](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/noname0310/32/27103_2.png) [@noname0310](https://forum.babylonjs.com/u/noname0310)\
**Post date:** [November 2, 2025, 7:10am UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/1 "2025-11-02T07:10:28Z")

</div>

I attempted to use SSAO2 in my project, but due to several minor defects, it is currently unusable for my use case.

Below, I will describe the bugs I discovered and the workarounds I found.

1. Currently, SSAO2 does not dynamically adapt to changes in the camera projection mode.

2. The Perspective Camera does not respect `camera.fovMode`.

To fundamentally resolve issue 1, the SSAO2 definition must be dynamically updated based on the camera’s `mode`.

To address this, I tried adding code immediately below the section in SSAO2RenderingPipeline that assigns the activeCamera.  
I added code to memorize the camera’s previous `mode` and update the define if it differs, but it didn’t work properly.  
It seems I need to place that logic somewhere else.  
[Babylon.js/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts at master · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts#L538-L539)

I tried to fix the bug myself, but my skills aren’t up to the task, so I’m asking for help.😇

To add an example of how it malfunctions, it appears like this.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/2/f2435b9420953a0415491ef24e69d897c36d783d.jpeg)

If you do not dynamically change the camera’s `mode` and `fovMode` parameters, it will render like this. (normal)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/c/3ca7f8397dd08ea9617746abc1b59fea0d765390.png)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 2, 2025, 9:16am UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/2 "2025-11-02T09:16:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![noname0310](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/noname0310/32/27103_2.png) [@noname0310](https://forum.babylonjs.com/u/noname0310)\
**Post date:** [November 2, 2025, 12:08pm UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/3 "2025-11-02T12:08:08Z")

</div>

I’ve created a PG that reproduces the issue here. I sincerely hope this problem gets resolved!

Thank you in advance. @Evgeni_Popov

> **[Babylon.js Playground](https://playground.babylonjs.com/#L2DGB4)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 3, 2025, 6:16pm UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/4 "2025-11-03T18:16:32Z")

</div>

Thank you for the detailed report and the reproduction!

Here’s the fix:

> <https://github.com/BabylonJS/Babylon.js/pull/17383>
>
> See https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamical…ly-changing-camera-parameters/61245

---

<div class="post-metadata">

**Author:** ![noname0310](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/noname0310/32/27103_2.png) [@noname0310](https://forum.babylonjs.com/u/noname0310)\
**Post date:** [November 4, 2025, 1:40am UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/5 "2025-11-04T01:40:58Z")

</div>

I reviewed the PR and found a few things that needed improvement, so I created a new PR. Thank you so much.

> <https://github.com/BabylonJS/Babylon.js/pull/17388>
>
> This PR complements #17383
> 
> \### SSAO camera fovMode support 
> 
> This is the se…cond topic I posted on the forum. 
> https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245
> 
> \### Initialization with Ortho Camera Fix
> First, the code in #17383 does not function correctly during the initial camera mode initialization.
> \`\`\`typescript
> this.\_originalColorPostProcess.onBeforeRenderObservable.add(() =\> {
> const camera = this.\_scene.activeCamera;
> if (camera && this.\_currentCameraMode !== camera.mode) {
> this.\_currentCameraMode = camera.mode;
> this.\_thinSSAORenderingPipeline.\_ssaoPostProcess.updateEffect();
> }
> });
> \`\`\`
> Because at the initial point when this callback executes, \`this.\_thinSSAORenderingPipeline.\_ssaoPostProcess\` is null.
> 
> Therefore, the camera's initial projection \`mode\` is ignored, and since the ORTHOGRAPHIC\_CAMERA define is never set, it only functions correctly for perspective cameras.
> 
> To resolve this, initialize \`this.\_thinSSAORenderingPipeline.\_ssaoPostProcess.camera\` with \`activeCamera\` once at line 331 in \`ssao2RenderingPipeline.ts\`.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 4, 2025, 9:01am UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/6 "2025-11-04T09:01:12Z")

</div>

Oh yes, sorry, I forgot to take `fovMode` support into account!

Thanks for the PR.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [November 7, 2025, 12:22pm UTC](https://forum.babylonjs.com/t/ssao2-does-not-behave-correctly-with-dynamically-changing-camera-parameters/61245/7 "2025-11-07T12:22:41Z")

</div>


