Melding Two Shadow Generators into a Single Shadow

I have a scene with two shadow generators, one for dynamic shadows and one for static shadows. They work as expected, but I would like the shadows to meld together seamlessly so that they appear as one unified shadow. How can I adjust the alpha mode or any other parameters to achieve this effect?

see the attached image for reference.

image

I am using BABYLON.CascadedShadowGenerator and BABYLON.DirectionalLight

Any suggestions or guidance on this would be greatly appreciated!

1 Like

I’m curious if there is a solution, but I think the effect as presented is already representative of physical reality, maybe not the exact blend.

1 Like

I’m not sure I can see a direct way to do it

Did you try to play with ShadowGenerator | Babylon.js Documentation (babylonjs.com) ?

1 Like

I’ve been there, and played around and I don’t see any properties/methods that can achieve this, but no worries, I just wanted to experiment with shadows.

I see that using two shadow generators (static/dynamic) seems to improve performance in my game so mission accomplished :slight_smile:

1 Like

It’s quite common to use alpha transparent sprites to emulate shadows in games like yours.

I could recomment lightmaps but you’ll end up with a huge lightmap texture for the whole level/world in your game.

1 Like

Thanks for the tip, I have no experience with lightmap and I will have a look into it and see if I can generate shadows for my static meshes dynamically.

Yes, I do agree with this comment. Light adds to light. And shadow adds to shadow. Therefor, a smaller object (the player or NPC) in front of a larger (i.e. a tree) casts a darker shadow which adds to the shadow of the tree. May be some fine-tuning but overall, pretty realistic, if you ask me.

For having tested and used this approach a couple or a few times, I’d say… Yes. If you are pretty much happy with the render, I think you can stick with this method (of course, my opinion only :wink:)

1 Like

@webgrid are both from the same light ?

Cause the best way would be to allow the dynamic one to clear itself with the content of the none dynamic one.

1 Like

I have both dynamic and static lights. Additionally, I exclude some meshes from the dynamic light to prevent them from casting shadows.

I wasn’t aware that cascading shadow generators could share a light. I haven’t been able to get that to work ?

Nope cascading ones would not work this way, did not noticed it was using cascades.

@webgrid May be not necessary, is it? If not, the solution of

sounds like a good idea to me :smiley:

I mean, I know I said that having stronger shadow on front objects is ok (kind of realistic) BUT…that’s only true when the static shadow is rather soft and not entirely dark/shadowed. Else, it creates a real weird feeling. There should be a maximum (black point) shadow when in full shadow and any other shadow that comes on top of it should NOT ADD to it.