1
$\begingroup$

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.

example image

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Edgel3D Aug 13 '18 at 6:40
  • 1
    $\begingroup$ It looks like this option doesn't exist for Cycles Render. But I think it will be possible in Blender 2.8. $\endgroup$ – moonboots Aug 13 '18 at 7:10
  • $\begingroup$ @Edgel3D Ah thanks, that works but only for blender render. Is there a cycles equivalent? $\endgroup$ – Uncle Yonkers Aug 13 '18 at 9:43
  • $\begingroup$ @moonboots Oh they are? Can you elaborate? $\endgroup$ – Uncle Yonkers Aug 13 '18 at 9:44
3
$\begingroup$

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"

shader LitObjectIDX(  
         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.

enter image description here

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)

EDIT in response to comments:

Yes you can have more than two colors, because you can do anything you like with the Object IDs. In this example, the objects have IDs of 2,4,6,8 and 10 respectively, and the plane they're sitting on has an ID of 12.

enter image description here

Here, I've got rid of the bounced diffuse light the clunky way, by simply going to the Properties > Cycles Settings of all the objects except the plane, and unchecking the 'Diffuse' ray visibility in each of them. That means they make no bounced diffuse contribution to the lighting in the scene at all.

If you wanted more control than that, you could use a combination of the Light Path node with the OSL node given here, in the shading of the objects, to specify which other objects received a diffuse contribution from them, and how. (That would be treating the objects in much the same way as we have treated the lamps in this answer. From the point of view of their diffuse, light-scattering rays, objects are lamps ... sort of.)

For the use of the Light Path node, and getting your head around reverse ray-tracing, I think this is a nice tutorial.

$\endgroup$
  • $\begingroup$ Ah NICE! Thank you, I got it to work but I just have two questions. Will I be able to do this with more than two colors? Like how would I be able to do this with 3-5 objects? And I don't want to sound greedy but is there anyway to get rid of the light bouncing off of each other? Its able to ignore the direct light source but not the light reflecting off of the actual object i.imgur.com/Q99cQiC.png $\endgroup$ – Uncle Yonkers Aug 13 '18 at 23:24
  • $\begingroup$ This is absolutely amazing, thank you so much $\endgroup$ – Uncle Yonkers Aug 15 '18 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.