• 3D
  • Object-wise shadow mask?

What chances are there of having shadows of some GeometryInstances affect only a selection of other GeometryInstances? I am working on a true 2D top-down game (no isometric view) with stacked layers (middle and front) and don't want some occluders in the middle layer to throw shadows onto the front layer. I know there are the VisualInstance layers, light_cull_mask and Camera cull_mask, however, they obviously can't be used for that [1]. An example of desired behavior would be that shadows are only cast for matching VisualInstance layers of objects. With respect to the current render pipeline: would such a behavior be possible at all? The shadow map e.g. for OmniLights doesn't carry information on the source geometry so that a shadow selection in the target objects shader seems rather difficult..

[1] except multiple Viewports are used and this is fixed: https://github.com/godotengine/godot/issues/43827

Are you asking how to only cast shadows on certain areas and not others, like this?

What I did was set the section that itsn't supposed to be affected by certain lights to not have a cull mask, and gave it a shadeless canvas material.

Thanks for your fast response! In fact my front layer needs to be affected by every light. And by every shadow except the ones cast from a specific group of objects.

I've never tried to have light only affected by certain colors before, but...

Like the collision masks and layers, Light masks and layers must match if you want lights to shine onto them.

They are in the inspector when you select the light(s) and occlusions.

You can effectively block light with one occluded, which will also be able to ignore the light you don't want.

I am in 3D but also in 2D this doesn't do the trick. Those settings are on a per-light basis. I need the same light cast shadows or not depending on the identity of the two interacting objects (i.e. caster and castee). The only theoretical workaround I currently see is culling away the occluders & its shadows using additional Viewports/Cameras as render targets. Practically, however, shadows of culled GeometryInstances are still visible (see quoted bug in my 1st post).