6
$\begingroup$

I need to trace the shadows of an object, like getting a red line around the shadow(shadow itself is not red). I know how to trace an object itself but not the shadows on that object. Is there a way I can do this?

$\endgroup$
1
  • 2
    $\begingroup$ I'm not sure what you are looking for. Is it possible you could add a screenshot or something showing what you mean by a "trace"? $\endgroup$
    – gandalf3
    Apr 4 '18 at 20:43
8
$\begingroup$

You can pick out the edges of the shadows by using the compositor as follows :

highlight shadows

The key is to enable the Shadow pass in the Render Layers (right-hand-side of the screenshot). In addition, enable the Object Index pass to give some control over which objects in the scene will have shadow edges highlighted - otherwise all objects will show highlights on all shadows, even where they are shadowing their own faces (presumably not desired).

This works by taking the Shadow pass (which just shows the shadows) and passes this through a Dilate/Erode filter to slightly shrink back the shadows, followed by a Subtract node to get the difference between the original shadows and the ‘shrunk’ shadows - this will pick out the edges. The ID Mask filters out only those objects with Object Index of '1' (which in this case is just the 'floor') and this is combined with the shadow edges using a Multiply maths node so as to only highlight shadows on the ‘floor’. The result is used to mix between the original render and a solid colour (red) which highlights the edges.


EDIT : To show all shadows (including 'self' shadows where an objects blocks its own light) you can use a simpler setup, not requiring the object ID :

all shadows

Note that the 'background' also counts as a 'shadow' - hence the line on the outer edge of the floor plane.

$\endgroup$
3
  • 3
    $\begingroup$ I said to myself: "Self, if anyone has any idea how to do this it would be Rich" lol $\endgroup$
    – icYou520
    Apr 4 '18 at 21:59
  • $\begingroup$ This is exactly what I was thinking. And yes I also want the line on the faces. To achieve that effect I enable the Object Index pass I assume out of what you said. Thank you SO much! $\endgroup$ Apr 5 '18 at 14:23
  • $\begingroup$ You're welcome - glad to help. I've included an edit showing the setup without the Object Index - so showing all shadows, including 'self'. $\endgroup$ Apr 5 '18 at 16:18

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.