# Losing light information when exporting to glb from the sandbox

**URL:** <https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404>\
**Category:** Content creation (3dsMax, Maya, Blender, glTF)\
**Tags:** sandbox, 3d\
**Created:** [September 12, 2024, 3:06pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404 "2024-09-12T15:06:16Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 12, 2024, 3:06pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/1 "2024-09-12T15:06:16Z")

</div>

Hi everyone,

In the sandbox, I add a directional light with a cascadedShadowGenerator to my scene.

 ![1](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/8/58a0db60ffdb8bd773c7b80502fd01513d0ddeee.png)

Then I export it as a gltf file, making sure I export the lights:

 ![2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/6/063daea18bcca9026476419a1a007010d032aa6f.png)

When exporting it as a glb file, the light component seems to have beenreset, as the only light I find is a directional with its position/direction reset and no shadow generator enabled. Sometimes, there even isn’t any light generated. I don’t know what’s going wrong.

Also, the lighting appears wrong when I import it via code in my project. The ambient lighting is gone, making the shadows pitch-black. is there any way to recover the post-processing/default lighting from the sandbox?

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [September 12, 2024, 3:16pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/2 "2024-09-12T15:16:05Z")

</div>

Hello again 🙂

> [@ClementSXD](#):
>
> I add a directional light with a cascadedShadowGenerator to my scene  
> […]  
> Then I export it as a gltf file, making sure I export the lights

`.glb` file is a standard format for exporting 3D assets, including **basic** shaders, as weel as embedded textures. It’s not related to Babylon JS.

You cannot use `.glb` to store a specific Babylon JS scene configuration (such as some settings about cascade shadow maps or whatever), as well as in Blender you cannot save complex custom materials or blender-related stuffs in `.glb`

* * *

Maybe you can explain a bit more what you are trying to achieve ?  
For example, on my side I never use `.babylon` format, not because it’s bad or whatever, but because for the usage I do of BabylonJS, I prefer keeping everything proper to 3D (assets, textures) in some binary files, and anything proper to BabylonJS (scene setup, whatever) in pure Javascript on the client side.

---

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 12, 2024, 3:22pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/3 "2024-09-12T15:22:08Z")

</div>

Oh hi again 🙂

I kind of expected that answer, sadly. I wanted to use a glb file to keep the size of my scene as small as possible, but used a babylon file to add lights and shadows without having to do it by code. Not that I can’t do it; I’ve actually tried to implement it, but the performance was so bad I looked for alternatives. From what I’ve seen, the shadow generator in the babylon file gave me the performances I wanted, and so I went for it.

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [September 12, 2024, 3:26pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/4 "2024-09-12T15:26:10Z")

</div>

If you goal is to reduce storage, most likely the weigth comes from the assets themeselves (3D geometry, textures)

The other stuffs, such as the scene configuration, when you store it in a `.babylon` file, I’m not 100% sure (let’s say 99% 😁 ) but I would say it’s the same than doing it by code in Javascript side. I guess that the .babylon file loader, just reads the `.JSON` file and executes some JS code to build the scene, based on the content of the JSON.

So at the end, I see no reason why storing some configuration in a .babylon file would give better performances than executing the same code manually 🤔

I’ll wait for BJS devs to see this topic and eventually bounce on it 😛

---

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 12, 2024, 3:29pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/5 "2024-09-12T15:29:07Z")

</div>

Yeah, my scene is really heavy, I’m working on optimizing it. I’ll probably go back to writing the shadow generator myself as well, sinc this seems like the most flexible option and would allow me to use a glb file.

But wait, if the glb file cannot store such information, why does the sandbox even have a toggle to export lights or not? It’s a bit confusing.

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [September 12, 2024, 3:33pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/6 "2024-09-12T15:33:02Z")

</div>

> [@ClementSXD](#):
>
> if the glb file cannot store such information, why does the sandbox even have a toggle to export lights or not?

I know that glb does support some basic lighting config. So, I guess it’s here to take advantage of it, but in the limitation of what GLB is supporting, VS what is specific to BabylonJS implementation itself…

---

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 12, 2024, 3:34pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/7 "2024-09-12T15:34:11Z")

</div>

Ok, thank you. I guess I’ll have to reimplement the lighting myself, and see what was wrong with my code. Thank you for your time.

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [September 12, 2024, 3:34pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/8 "2024-09-12T15:34:50Z")

</div>

Maybe @Evgeni_Popov can help, as far as I know, he is the mastermind behind the cascade shadows of BJS 😛

---

<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:** [September 12, 2024, 8:01pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/9 "2024-09-12T20:01:34Z")

</div>

I don’t know exactly what I need to check? Regarding shadow configuration in .glb files, it is indeed not supported by the file format.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [September 12, 2024, 8:11pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/10 "2024-09-12T20:11:43Z")

</div>

Instead of Cascaded Shadows (which may be heavy for performance in some cases) you may use some other ShadowGenerator.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 12, 2024, 11:44pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/11 "2024-09-12T23:44:45Z")

</div>

> [@ClementSXD](#):
>
> the light component seems to have beenreset, as the only light I find is a directional with its position/direction reset

glTF does not support shadows, but it should get the transform of the light correct. If you can provide a repro, I can investigate.

---

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 13, 2024, 10:07am UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/12 "2024-09-13T10:07:46Z")

</div>

Hi, to reproduce it, I simply import a 3D model, add a directional light, and export the scene to glb. Then, I reimport that glb scene and check the light’s data in the inspector. It doesn’t matter if it’s the sandbox, playground or my project, all of them display the wrong transform for the light.

---

<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:** [September 13, 2024, 2:34pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/13 "2024-09-13T14:34:23Z")

</div>

Please share your model if you don’t mind 😉

---

<div class="post-metadata">

**Author:** ![ClementSXD](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@ClementSXD](https://forum.babylonjs.com/u/ClementSXD)\
**Post date:** [September 13, 2024, 2:40pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/14 "2024-09-13T14:40:36Z")

</div>

Here : [Unique Download Link | WeTransfer](https://we.tl/t-e0tebw1C6a)

It’s just an empty scene with a directional light. Nothing grand. When I export this to glb, it loses the position and direction of the light.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 13, 2024, 11:01pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/15 "2024-09-13T23:01:42Z")

</div>



---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 26, 2024, 3:52pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/16 "2024-09-26T15:52:24Z")

</div>

Sorry for the delay. I missed replying earlier.

The position and direction of the light isn’t lost. The loader loads a light from a glTF by creating a transform node with the light’s transform as the parent of the light.

That said, I noticed the light direction is wrong, which is a different problem.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 26, 2024, 3:52pm UTC](https://forum.babylonjs.com/t/losing-light-information-when-exporting-to-glb-from-the-sandbox/53404/17 "2024-09-26T15:52:29Z")

</div>


