I'd like to shade the edges of my objects darker, like a toon shader, based on abrupt Z depth transitions to neighboring pixels -- in other words wherever the Z gradient is high, darken the image. I imagine that can be done in the compositor (?), but can it be done in object space in the material shader editor?

Something like this (not from Blender): Real images on left, Z-edge shaded on right

  • $\begingroup$ Can you show an example of result? $\endgroup$
    – Carlo
    Jan 19, 2021 at 20:31
  • $\begingroup$ Added a couple of samples of what I'm looking for. $\endgroup$
    – GaryO
    Jan 19, 2021 at 20:50
  • $\begingroup$ Have you tried freestyle? $\endgroup$
    – susu
    Jan 19, 2021 at 20:54
  • $\begingroup$ blender.stackexchange.com/questions/192498/… $\endgroup$
    – susu
    Jan 19, 2021 at 20:56
  • $\begingroup$ I have tried using Fresnel but that's only based on the normal (dot product of normal and eye vectors), not Z distance discontinuity, so it doesn't pick up edges of a flat object. Works OK for spheres though. $\endgroup$
    – GaryO
    Jan 19, 2021 at 21:13


You must log in to answer this question.

Browse other questions tagged .