How to get directional light to pass through ceiling and cast shadows on floor

So I’m trying to cheat a bit with light baking shadows of my furniture assets in my office model by setting up a directional light that is angled straight down to simulate ceiling lights. However, I am running into a couple of issues. I perused the shadow generation/lighting docs and searched the forum, but couldn’t find answers beyond generic setup, etc.

So 1.: the directional light is casting shadows only for meshes, not instanced meshes (I have instances of the same chair spread through the office, for example). Is there a way to get instanced meshes to cast shadows without having to convert them to a Mesh?

Example, for reference:
source Mesh has top-down shadow casted (subtle, but there):

Instanced Mesh does not have shadow casted:

And 2.: the light baking only works when the ceiling is not enabled and is invisible. I don’t add the ceiling meshes (which are basically just planes with a jpeg as the material that have backface culling on) to the shadow generator, and I have receiveShadows == false for those ceiling meshes as well. Is there a way to get the light to pass through the ceiling meshes to cast shadows from the furniture onto the floor?

And, conversely, when the ceiling is hidden and I am looking down in a floorplan perspective, is there a way to hide the ceiling, but make the second directional light (simulating the sun, which is angled down at, for instance, 30-45 degrees) not shine over the walls of the office and instead just come through the windows, so that the lighting shown in the floorplan view reflects the lighting that you would see in the office with the ceiling on (so basically, hiding the ceiling but having the sun light, specifically, interact with the ceiling as if it were shown/enabled?

You can see the overflow of light spilling over the top of the walls/windows in this capture. The light should end where the window shadows end:

Thanks in advance!

Hi @johntdaly7, pinging @Evgeni_Popov to see if he can help you.

If you push the instanced meshes in the shadow caster list they should generate shadows. If it does not work, can you provide a repro?

Shadow casting is driven by the shadow caster list, and shadow receiving by the receiveShadow property. If the ceiling mesh is not pushed to the shadow caster list, it won’t generate shadows and won’t block light, even if visible. Again, a repro would definitely help here, as it should simply work.

If the walls are shadow casters, the light won’t shine through them, shadows will be generated on the floor for those walls. If you want the ceiling to generate shadows without being visible on screen, set the disableColorWrite and the disableDepthWrite of its material to true. For eg:


Thanks for the response! @Evgeni_Popov

So I made these changes, and I think I might have some code issues, because the shadowGenerator1 has meshes added to the shadowGenerator1’s renderList twice. I have two shadowGenerators, per directional light. I checked my code (CTRL-F’d it) and only add to the shadowGenerator1 once, but mayb does the shadowGenerator2 share the renderList with shadowGenerator1? ShadowGenerators don’t work like that, right? That’s my best bet as to why it might still be adding to the shadowGenerator and thus blocking sunlight. I’ll try to construct a playground but there’s so much happening in the code it might take a while to parse it out. Thanks!

I don’t know what happens when one uses two shadow generators for the same light, I don’t know if it’s supposed to work… Maybe try to duplicate your light instead and have a single shadow generator per light.

I do have a single shadow Generator per light, and they are separate. I’ll do some more digging. The first shadow Generator is the only one that receives duplicate meshes, which is weird. Thanks for the help!