Shadows on some layers, but not all

I have three layers and I would like sprites on the top layer cast a shadow on the middle layer but not on the bottom layer. Sometimes the middle layer has no objects and sometimes it does. I suspect this is not possible, I can add a shadow effect to a layer but that shadow effectively “falls” on every layer underneath and I can’t pick and choose which ones see the effect. Can anyone think of a way to achieve this?

Your assumption is correct. Effects are layer specific, and it is currently an all-or-nothing affair. Anything on said layer will have the effect applied to it, anything on a different layer will not.

Your best bet would be to move things to other layers that don’t have the shadow effect if you don’t want it to cast a shadow.

1 Like

Thanks but your suggestion won’t solve the problem. What I am really in need of is an effect I can apply to a layer that says any object in layers above me can cast a shadow on me.

So, for example, if I have three layers A, B and C, where A is the bottom layer, B is the middle and C is the top. I want to add this effect to layer B. As a result any objects placed in layer C will have a shadow drawn over layer B objects, but those shadows will not be drawn on layer A objects.

This might be possible to code up in Javascript but I wouldn’t know where to begin. Any JS experts here who can help?

Or here’s another idea, perhaps I can modify the current Drop Shadow behaviour to use a mask when drawing its shadow, and that mask is basically the inverse of the objects in a specified layer (or a list of specified layers). So when you’re drawing a shadow that has been applied to layer C, you only plot the shadow on top of objects that are in layer B, ignoring any objects in other layers. Who knows most about how the Drop Shadow behaviour is coded and whether this modification could be added to it?

I found the SpriteMasking behaviour and thought this would help, did a simple test and it seemed to do the trick, i.e. copy the sprite where I want the shadow to fall on top of and set that up as a mask on another sprite that provides the shadow. Unfortunately there appears to be a bug because if the sprite I’m using as a mask is big (i.e. an entire landscape) then GDevelop is hanging when it gets to 100% as the game loads :frowning: