# Model load much slower with cascadedShadow and prepassRenderer

**URL:** <https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893>\
**Category:** Questions\
**Created:** [May 17, 2023, 6:23am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893 "2023-05-17T06:23:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [May 17, 2023, 6:23am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/1 "2023-05-17T06:23:45Z")

</div>

My test playground: [Babylon.js Playground](https://playground.babylonjs.com/#G7B8J6). You should add a model path when testing.  
Sorry I can’t share the models for some reasons, but I’ve tested many models on many PCs with chrome, firefox and edge, but they all have the same problem on **5.47.0**.

For the most typical situation, I use windows 10,GPU RTX3060Ti with CPU i7-10700 on chrome 113.0.5672.93, and the first image is the param of the model with cascaded shadow opening.  
As you can see in the second image, it took me around 5 seconds to load the model with cascadedShadow and ssrpipeline(to enable the prepassrenderer) on. While only 1.5 seconds with only ssr enabled or only shadow enabled.  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/4/e47362ac0ac577da89aee410ea2ca8e34afb62c3.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/f/ffd93a3dc35e5bbfcc25eb16f99f8575fa76b2b9.png)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/d/7d3c6f62591703f3ac53bec4f28cada708a28d06.png)

Some things I recognized that maybe useful:

1. Only cascadedShadow will cause the problem, it works fine with simple shadow.
2. Neither the cascaded count of the shadow nor the faces count of the meshes can effect.

So is this situation as expected? Or any workaround would really help.

Edit: I’ve read the [post](https://forum.babylonjs.com/t/loading-time-performance-regression/28504/37), though not really sure, it is not a same problem.

---

<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:** [May 17, 2023, 9:29am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/2 "2023-05-17T09:29:45Z")

</div>

I don’t reproduce.

I used this PG: [https://playground.babylonjs.com/#G7B8J6#1](https://playground.babylonjs.com/#G7B8J6#1)

Can you test with WebGPU / Firefox (or another browser)? Maybe it’s a problem with your drivers(?)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 17, 2023, 12:33pm UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/3 "2023-05-17T12:33:26Z")

</div>

Updated the PG just to print the elapsed time to load: [Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#G7B8J6#2), tested on Edge and FF and both were taking the same time. Are you sure you disabled the cache when you tested? Most of the time I saw was just regular download time.

---

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [May 18, 2023, 12:47am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/4 "2023-05-18T00:47:44Z")

</div>

Your playground works fine for me, I guess the model is too simple to reproduce the problem, so I updated the playground with the model from [Loading time performance regression?](https://forum.babylonjs.com/t/loading-time-performance-regression/28504).  
New playground: [https://playground.babylonjs.com/#G7B8J6#5](https://playground.babylonjs.com/#G7B8J6#5).

---

<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:** [May 18, 2023, 10:47am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/5 "2023-05-18T10:47:46Z")

</div>

Still the same thing for me between cascaded / non cascaded: first time I come to the page, it is 1.03 - 1.08s for both, then when I click on the “Play” button, the time is around 0.75 for both.

---

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [May 18, 2023, 12:18pm UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/6 "2023-05-18T12:18:37Z")

</div>

The elapsed time showed is similar with or without the cascaded, but the time from clicking the ‘Play’ button to the GUI shows is really different, around 5s with the cascaded and 1.5s without the cascaded.  
I’ve tested the playground over 5 computers and all the same problem, so I really don’t think it is a problem with hardware or driver.  
May I ask are you using the playground#5 or just copy the model link? I just noticed you recalled `createDefaultCamera` in onsuccess callback in playground #1 and #2, this will cover up the problem.  
Edit: The stuck time actually happened on the first time render but not load, sorry I don’t make it clear before.

---

<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:** [May 19, 2023, 4:15pm UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/7 "2023-05-19T16:15:39Z")

</div>

Assigned @Evgeni\_Popov on May 19, 2023, 4:15pm UTC



---

<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:** [May 19, 2023, 8:25pm UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/8 "2023-05-19T20:25:23Z")

</div>

I can reproduce, I’m currently investigating the issue.

---

<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:** [May 24, 2023, 11:32am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/9 "2023-05-24T11:32:08Z")

</div>

See my answers in this thread:

> [@How to detect the completion of initialization](https://forum.babylonjs.com/t/how-to-detect-the-completion-of-initialization/40952/14):
>
> This PR will make sure that everything is ready before scene.isReady returns true, even when using the pre-pass renderer:

---

<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:** [May 24, 2023, 11:32am UTC](https://forum.babylonjs.com/t/model-load-much-slower-with-cascadedshadow-and-prepassrenderer/40893/10 "2023-05-24T11:32:11Z")

</div>

Unassigned @Evgeni\_Popov on May 24, 2023, 11:32am UTC


