23. Parallel Hair Programming

Kaveh Kardan
2 min readMay 8, 2022

At Taarna I expanded the scope of my work to include development of hair and clothing systems, both important for character animation.

I went back to my mass-spring simulation models from my Symbolics Lisp Machine days at the MIT Media Lab. Armed with much beefier processing power — five years of Moore’s Law — , including an 8 (or was it 16?) processor SGI machine, it was a fun challenge.

One of the techniques I pioneered (or independently invented, not sure what the correct terminology is) was that of guide hairs for grooming hair. Here’s what I came up with. I took a 3D model of the character’s head and deleted all the polygons except the areas where hair would be growing. Typically the scalp and sideburns. I triangulated this mesh. My hair software placed one hair strand at each vertex. These were “guide hairs” the user could manipulate and style.

To fill the surface of the scalp mesh with thousands of individual hair strands, I remembered the concept of barycentric coordinates from one of my math classes at MIT (I was a math major after all). By generating barycentric coordinates within each triangle I could easily fill each triangle with as many hairs as desired.

The hair strands would follow the shape of the guide strands across the triangles by interpolation. If you wanted a discontinuity such as a hair part, you would need to have non-shared vertices in those parts of the mesh, analogous to how we did hard edge shading.

At Taarna we used Pixar’s prman renderer, based on their Renderman standard. One of the first (of many) Renderman shaders I wrote was for doing anisotropic shading of hair strands.

For animating the hair, I used my trusty spring-mass model to simulate the motion of the guide hairs, and all the other hairs would follow that motion with smooth interpolation.

Design & Code

I didn’t get to do any development yesterday. It was a tumultuous day that included a downed power line, multiple power outages, and a visit from the fire department.

So I thought I’d share my main.lisp file with you instead. The Common Lisp developers can observe the complete lack of a defsystem or proper use of packages and namespaces. Definitely not best practices.

I don’t even have a proper name for this project yet. Need a cool codename.

Next Episode

--

--

Kaveh Kardan

MIT mathematics degree • wrote animation software used in “Jurassic Park” • software R&D lead on “Final Fantasy” movie • software dev on “The Hobbit” films