2
$\begingroup$

When I overlap 2 objects like this

enter image description here

resulting freestyle lines are like this

enter image description here

But I want render overlapped edge lines like this(red lines below picture)

enter image description here

What's the easiest way to accomplish my purpose?(A lot of objects in my work are made in that way so resulting render image misses many overlapped edges. I tried to remake some object to reveal overlapped edges but I realized that remaking all objects is too hard to me.)

$\endgroup$
6
  • 1
    $\begingroup$ It seems not possible: blender.stackexchange.com/questions/52526/… $\endgroup$
    – lemon
    Aug 1 '19 at 8:21
  • $\begingroup$ thank you. but i'm really sad. $\endgroup$
    – 나미손
    Aug 1 '19 at 8:51
  • $\begingroup$ I've tried to do it with 2.8 using the Workbench engine. Not perfect but maybe have a look to it. $\endgroup$
    – lemon
    Aug 1 '19 at 8:57
  • 1
    $\begingroup$ You may want to checkout LANPR which is currently in development as a possible freestyle replacement. $\endgroup$
    – Robert Gützkow
    Aug 1 '19 at 9:37
  • $\begingroup$ Do you want face intersections, or hidden edges? $\endgroup$ Aug 1 '19 at 10:17
3
$\begingroup$

This isn't possible (as far as I know) using freestyle. However, it is possible to fake the effect in the Compositor by looking for sharp changes to the rendered Normal and/or Depth.

To achieve this, we need to compare each point in the render with a neighboring point and highlight those areas where the Normal or the Depth varies by a significant amount between those points. This can be acieved with a node group as follows :

node group

Here we take the Depth and Normal as inputs and translate each by a specified X and Y (multiplied by the desired Thickness) - this allows the current pixel to be compared with a neighbouring pixel.

For the Normal, the RGB Subtract node compares them and the result is separated into its components and its overall magnitude calculated (as 'sqrt(r^2+g^2+b^2)'). If the result is greater than a Threshold we have found an edge.

Similarly, the Depth is subtracted from its neighbour and the Absolute result compared with a second Threshold. The two results are combined using the Maximum.

In order to avoid artifacts from features in particular directions, we can sample neighbouring pixels in different directions. This can be achieved with multiple node groups with different X and Y offsets - one above, one below, one to the left and one to the right (ie, (0,1), (0,-1), (-1,0), (1,0)) and the results combined as follows :

nodes

This can produce the following results (after tweaking the line thickness and thresholds) :

result freestyle

$\endgroup$
2
  • $\begingroup$ Can we avoid a few nodes here, by letting something like Filter > Sobel do the convolution of the Normal pass etc. for us? $\endgroup$ Aug 19 at 11:54
  • $\begingroup$ @robinbetts IDK, possibly. Feel free to submit and answer using another method. I’m not really familiar with how that filter operates. $\endgroup$ Aug 19 at 13:07
3
$\begingroup$

This is essentially the same method as @Rich Sedman's; he is passing a convolution kernel over an image to detect edges, 'by hand'. Whereas this is necessary in shader nodes, (if you are trying to kick the renderer into doing it,) in the compositor, various edge-detection filters are provided:

enter image description here

Here, a Sobel filter is passed over the Normal output, to detect edges in it. You may tweak the other nodes to your desired outcome: here, the Dilate fills some gaps, the Color Ramp converts to B/W, with a soft threshold, and the Blur antialiases the result, somewhat.

As in Rich's answer, the same edge-detection could be applied to other discriminators, such as depth, depending on your scene.

$\endgroup$
1
  • 2
    $\begingroup$ Very nice - that is far simpler. $\endgroup$ Aug 19 at 15:53

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.