Shadows + PointLight = too many draw calls

Hello guys I have asked about this problem earlier (point light and shadows = too many draw calls). I have been told about something like “cube algorythm” or whatever and that it is just supposed to cause lot of draw calls. I understood that it would need 6 draw calls per mesh (as cube has 6 sides) but as I dig deeper I noticed that it causes LOT more.

In my actual experiemt I had my scene WITHOUT any shadows = 43 draw calls.

Then I added one MESH as a shadowcaster for my light and it rised to 65 draw calls, adding 2 more meshes caused rise to 100 draw calls and it continued this way.

It seems like that every mesh added as shadowCaster increases drawCalls by like 15 - 20 and it has disastrous impact onto performance.

My question is simple, is it as it supposed to be ? I can live with that and only allow shadows on full-blown desktop PCs, but if there is something I can do with it, I would like to. Sadly 3 shadow-casting meshes at this momemt causes as many drawCalls as my whole scene :frowning:

Note: I only add these meshes as shadowCasters to ONE LIGHT (there are another lights on the scene, but I add meshes to only this one).

Thanx too much for some answer and if it is absolutely clearly ok, then please delete this topic as I feel like I am spamming this forum way too much :))

Shadows require to render the entire scene (well at least the shadow casters) to the shadow map.

if the light is a point light the shadow map is not a 2d texture but a cube texture meaning that you need to render each shadow caster 6 times (one per cube texture face). And this will happen for each light that casts shadows

I would need to see a repro in the playground to give you a better explanation for your scene

Thanx ! I believe that I understand is as you said - it only renders shadowCasters right ? Then one shadowCaster shall add 6 draw calls I believe, but as I see, it adds like 15 or such.

I am afraid that I cannot reproduce it in PG as it is probably caused by some other causality that I cannot isolate (because I dont know about). I will try to make it simpler and try it with simpler scene and then I will see.

Important for this moment is fact that one shadow caster shall add exactly 6 draw calls right ?

Yes.

2 draw calls (sphere and plane):

8 draw calls (only sphere is shadow caster, light is a point light):

1 Like

Thanx both of you guys !! As I have minimized my scene I have found that the thing that is supposed to be 1 mesh is actually 2 meshes :frowning: and thats why it caused more draw calls. And another thing that contributed to my bias was that draw calls that are displayed in debugger fluctuate little bit when some shadows have set getShadowMap().refreshRate to some value greater than 1.

Now I have found my mistake and owe you beer :))) actually it would be several beers by this time :slight_smile:

You can actually delete this thread to keep forum clean ?

Thanx once again !

1 Like

No worries! It is important to understand and we are all happy to help