# Is it possible to have an object ignore a certain light source but still be affected by others?

I want to create an effect on a character where their skin and clothing are effected by two different light sources. The clothing should only reflect a bright bounce light, but have the skin should not be affected by this light source.

In the example image I have two objects a cube, a sphere and three emission lights . I want the two white lights to hit both objects, and I need the purple light to hit and reflect off of the sphere, but ignore the cube entirely (no reflections).

Someone suggested to composite the layers together, it works... but this is very impractical and cumbersome because it forces the background to be transparent and it will be a pain to try and layer together a more complex scene, especially if its animated which is what I want this effect for.

I know you can have objects ignore shadows and all kinds of other things so im hoping someone knows how to get an object to ignore light with a few settings.

• Obviously I haven't all the facts here but on the face of it and I usually render in OpenGL, but I do this frequently and I've not had to use the compositor, nor have I ended up with transparent backgrounds. If two layers are used and the sphere is placed in the 2nd, along with a purple lamp set to "This layer only" the cube in the 1st layer won't be affected by the extra lamp. The lamp(s) in this layer would have "This layer only" unticked. – Edgel3D Aug 13 '18 at 6:40
• It looks like this option doesn't exist for Cycles Render. But I think it will be possible in Blender 2.8. – moonboots Aug 13 '18 at 7:10
• @Edgel3D Ah thanks, that works but only for blender render. Is there a cycles equivalent? – Uncle Yonkers Aug 13 '18 at 9:43
• @moonboots Oh they are? Can you elaborate? – Uncle Yonkers Aug 13 '18 at 9:44

This way is more about having a light ignore the object, than having the object ignore the light. If you're prepared to use OSL and CPU rendering, (which may slow things down too much for you), you can use this little OSL script in a lamp's shader, which returns the index of the object it's lighting directly, for each ray sample.

#include "stdosl.h"

output float ObjectIdx = 0.0
)
{

if (trace(P,I)){
getmessage("trace", "object:index", ObjectIdx);
}
}


In the Render panel, enable CPU rendering, and OSL.

In the Properties > Object > Relations panel, assign a Pass Index to the objects you're interested in discriminating. In this example, there are two cubes - the one on the left has an index of 10, the one on the right, 20. They both have plain white BSDF materials.

One spotlight, shaded with the node tree shown on the left, is lighting the scene. With this set-up, it lights the left cube pink and the right cube green.(You could use the objects' indices in any way you choose, including ignoring all objects within a range of ID's)