NPR edge (contour) trick with compositor

Found an easy way to get object contours with compositor, may be someone find it useful

  • Works with cycles
  • Easy to setup
  • FAST (No freestyle!)
  • Animation friendly (sort of)
  • GPU friendly

How to setup (for Cycles rendering):

  • Enable “Experimental” features in render tab
  • Create two materials - “normal” and “grown”. See screenshot for “grown” material nodes, “normal” can be anything
  • Enable “true displacement” for “grown” material
  • Add two more RenderLayers with Z pass and fixed 1 sample. First render layer should use “normal” material as global override and second - “grown” material as global override
  • In compositor: add this two renderlayers and substract depth of first layer from depth of second
    …Magic!

The trick is in “grown” material - it uses displacement to “push” faces along normal, so contour pixels in second renderlayer will be closer to camera then same pixels of background in first renderlayer. Difference gives you nice controus, really fast (1 sample per whole scene)

https://pp.userapi.com/c841438/v841438036/36898/mGBGx7xyY9g.jpg

https://pp.userapi.com/c841438/v841438036/36891/kMOJXJBwZPw.jpg

Attachments