I want to create a procedural texture that will be based on the geometry of an object. How can I get distance to the nearest edge for the current pixel of an object in Cycles nodes? I hope it is possible. Without any UV mapping and obviously before splitting each face into triangles.

  • $\begingroup$ Short answer is nope. Sorry. Closest you can get is pointiness or a fake AO, or alter the surface geometry to use height/slope as a stand in for edge distance $\endgroup$ – 3pointedit Jul 17 '18 at 6:33
  • $\begingroup$ A custom OSL shader might be able to determine the information you are looking for. For example an OSL shader can be created to measure the distance to the nearest face. Can you provide an example of what you want to accomplish? $\endgroup$ – Ed Tate Jul 21 '18 at 22:18
  • $\begingroup$ im interested in this too!! $\endgroup$ – Sam Mousa Sep 1 '19 at 21:01

It's not the exact distance as you would say it, but it can be approximated using Bevel node in combination with Normal output of Texture Coordinate node.

The Bevel shader node can be used for rendering rounded corners. Like bump mapping, this does not modify the actual geometry, only the shading is affected. Slight rounding on edges helps to capture specular highlights that you would also see in the real world.

Bevel essentially gives blurred version of normal vectors depending on geometry, so you just have to measure the difference between them.

Shader node example


  • Samples controls smoothness
  • Radius means how farther from the edges will the samples taken
  • Alternatively use Color Ramp or Map Range node to control the falloff

Example results

Cube Ico Monkey

As I said it is not precise and can be lead to unexpected results such as:

  1. Edges marked smooth won't affect this
  2. Edge between two faces with little normal change will have a little effect on this
  3. You can't get exact value of a distance as it's done by random sampling, thus you can't do proper math with it(everything is either 0 or some fixed values)
  4. Faces with multiple edges converging will report higher values, due to the nature of the method mentioned above
  5. Render time will increase by 20% on average, as explained in the official doc.
| improve this answer | |
  • 1
    $\begingroup$ Sounds cool! Though it's not precise, but it is at least something practicable. Thanks (: $\endgroup$ – AivanF. Jun 13 at 8:43

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.