Render shadow only from specific light?

Is it possible to specify which light is used when an object casts shadows? I’d like to limit certain objects to cast shadows based only on certain lights while other objects cast shadows based on yet other lights.

f.e. If I have two objects next to each other, and two lights next to each other, I’d like for one object to cast a light from one light, and the other object to cast shadow from the other light.

Currently, it seems like if I set castShadow to true, then the objects will cast shadows from all lights in range, and I don’t see a way to change it.

Ah, we need this:, but it hasn’t arrived yet. :frowning:

This would really help to have different lighting for different sorts of objects (f.e. I want to light up DOM elements in the following demo in a different way than regular meshes so that lighting looks more convincing):

Because this is a feature request, it should be discussed on github. If you need this feature, upvote the issue and ask for progress. But i’ve seen you already did this :wink:.

As a workaround, try the approach mentioned here to achieve a similar effect like real selective lighting.

1 Like

That workaround is much too complicated, and may have undesired effects on other aspects of rendering (but I’m not sure about that). I’m really looking forward to the actual feature.

In my case, I’m passing all world transforms to the Object3Ds (autoUpdate is false), so I can just not nest the objects, and separate them into two scenes, so that all objects are just direct children of each Scene node. This might be easier to do in my case, but not in regular cases where people need Three.js to calculate world matrices.

is there any news on this “feature” in the latest build?

WebGPURenderer already supports selective lighting: three.js - WebGPU - Selective Lights

There is no support for WebGLRenderer and it’s not clear if it will ever be supported.

1 Like