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.
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
Radiusmeans how farther from the edges will the samples taken
- Alternatively use Color Ramp or Map Range node to control the falloff
As I said it is not precise and can be lead to unexpected results such as:
- Edges marked smooth won't affect this
- Edge between two faces with little normal change will have a little effect on this
- 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)
- Faces with multiple edges converging will report higher values, due to the nature of the method mentioned above
- Render time will increase by 20% on average, as explained in the official doc.