Are shadow-only lights possible?

Is it possible to have a directional light that only casts shadows without contributing any light to the scene?

My scene lighting is a combo of baked, IBL, and a hemi light and I don’t want any additional light – just the shadows from a “sun” light. Is this possible?

1 Like

Like this ? Babylon.js docs

Hmm maybe. The challenge is I want the shadow to fall on otherwise normally textured material lit by other lights and light maps. That shadow-only material seems to only render the shadow and nothing else. I wonder if I need add a quad to my scene whose sole purpose is to receive the shadow?

I’m not sure to understand. It’s not emissive + shadows?
Do you have some visual examples?

1 Like

I’ll try to explain better. Take this scene, lit only by IBL and lightmaps:

I want a shadow under the dynamic mesh, but I don’t want the additional light:

Can I preserve the lighting from image 1 but get the dynamic shadow from image 2?

that’s a question for @PatrickRyan :slight_smile:

@papajuan, yes, you can cull any mesh from a light by adding it to the light.excludedMeshes array. The calculations for lights and shadows are separate and have separate member lists, so you can exclude a mesh from being lit but include it in the shadow calculations for a light or vice versa. I added this on line 146 of your playground. You can see that the specular reflection from the directional light is gone in this PG while the shadow remains:

Not quite. The mesh I don’t want additionally lit is the floor – but I want the shadow.

It looks like the additional light on the floor is required to make the shadow. That is, the shadow isn’t actually darker, it just looks dark because the surrounding area has been made lighter by the added light.

light

Here’s is what I’d like to have (simulated):

Note that this is the original floor lit only by IBL and light map, and the shadow is making that spot even darker.

I’m starting to think that what I’m shooting for here is not possible?

Using the shadowOnlyMaterial as Cedric mentionned should definitely work ? You need to add a plane just above your ground with this material and exclude the casting light from all other materials.

We can help with the setup if you share a playground.

2 Likes