# Bug in fog serialization

**URL:** <https://forum.babylonjs.com/t/bug-in-fog-serialization/50033>\
**Category:** Bugs\
**Tags:** sceneserializer, fog\
**Created:** [April 26, 2024, 1:20am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033 "2024-04-26T01:20:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [April 26, 2024, 1:20am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/1 "2024-04-26T01:20:29Z")

</div>

1.“scene.fogEnabled” cannot be serialized  
2.When my "fogMode " is 0, parameters like "fogColor " cannot be serialized.

My procedure involves creating a scene with fog and exporting it. Upon loading, fogMode or fogEnabled can be invoked to enable fog with previously set parameters

---

<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 26, 2024, 1:25am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/2 "2024-04-26T01:25:32Z")

</div>

Wanna share a repro?

---

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [April 26, 2024, 1:37am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/3 "2024-04-26T01:37:24Z")

</div>

Due to the fact that I serialize the scene before opening it in other pages, it may not work properly in PG implementation. Here is my portion of code:

1. 

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/4/2444acd44b1c2abbe9791672d5ceb6fabe695609.png)

---

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [April 26, 2024, 1:41am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/4 "2024-04-26T01:41:14Z")

</div>

1. 

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

---

<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 26, 2024, 3:42pm UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/5 "2024-04-26T15:42:03Z")

</div>

When fogMode is 0, this is expected to not store fog data (to save size).  
`scene.fogEnabled` is not a property we store. It is intended to be used as a feature control.

What is your use case? Can you store with fogMode !== 0 and use fogEnabled to control it in your scene

---

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [April 27, 2024, 8:53am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/6 "2024-04-27T08:53:53Z")

</div>

I need to store various information about fog, and generate fog when I need it. But currently, I don’t have any method to achieve this

---

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [April 27, 2024, 8:56am UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/7 "2024-04-27T08:56:35Z")

</div>

fogMode and fogEnable cannot be implemented (fogEnable cannot be serialized, and when fogMode=0, all information cannot be stored). The only method I can think of is to enable fogMode first, and then immediately set fogMode to 0 after entering the scene. This operation is obviously unreasonable.

---

<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 27, 2024, 2:19pm UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/8 "2024-04-27T14:19:05Z")

</div>

That makes sense. Please create an issue for me on the repo and I will fix that next week

---

<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 27, 2024, 2:53pm UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/9 "2024-04-27T14:53:18Z")

</div>

nevermind I will do the fix now 😉

---

<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 27, 2024, 2:57pm UTC](https://forum.babylonjs.com/t/bug-in-fog-serialization/50033/10 "2024-04-27T14:57:30Z")

</div>

[Better individual store for fog serialization by deltakosh · Pull Request #15039 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/15039)
