Osl Improved Pointiness

by Tim Zoet in Materials, Shaders, Textures

OSL Improved Pointiness

The pointiness attribute in Cycles can be very useful for rendering worn edges and dirt maps. However, it is far from perfect. It offers little to no control over the thickness of edges, corners cause problems and, most importantly, if the size of any polygons in your model are different from each other or when they change, you can start over again with designing your materials. All of these problems are mainly caused by how Blender calculates pointiness: it simply interpolates values between vertices.

This OSL script does things in a completely different manner. It analyzes the geometry around a point that is being shaded. When rendering a point on a triangle, the script will calculate a short offset along the normal and then shoot random rays in a hemisphere around that offset point. Depending on whether it hits something, it will calculate the differences in angle (and will perform some more mathematical magic) between the normal of the point and the found hit point to determine whether it found a sharp edge, a corner or a flat face.

As you can imagine, these calculations take a lot more time than simply using the pointiness attribute. Because of this, the OSL script is not very suitable for direct use in your scenes. It is mainly intended to be used for baking textures. These baked textures can of course be used very easily in all of your scenes.

Features

  • Independent of polycount: Whether your model has a lot of detail, consists of only a 100 polygons or uses 4 levels of subdivision, the sharpness of an edge is calculated very precisely and consistently.
  • Aspect ratio and size of polygons: The size and aspect ratio of polygons does not matter anymore.
  • Corners and interpolation: No more weird interpolation errors around corners.
  • More control: Multiple values to very precisely control the look of the edges.

Product Updates

Version 1.1

  • Added another script that uses a somewhat different calculation, renders faster and is easier to use.