The collision system had to be fast so the most basic starting point is to use spheres to check the collisions. The opted for system was somewhat inspired by Nvidia's "Pearls" method for the Nalu demo and the theory behind the Adaptive Wisp tree. In basic terms, there are collision spheres arranged along the key hairs with respect to how many spheres are intended in total. When these spheres collide repulsive forces to keep them apart are added to the physics calculation. On top of this for speed the hairs are checked only against the hairs nearest to them for collisions. This is done by using a 3x3 filter on an array. The problems that still remain with the collisions though are that hairs only react to collisions rather than trying to prevent. This leads to a lack of equlirium if the collision spheres come into contact in the hair's rest position.
As the application is beginning to struggle for speed is seemed about time to implement a large optimisation. This quite simply was to remove the physics and related functon calls to a separate thread and leave only the rendering in the main program. As the only shared resource between these tasks is the vertex buffer which is only used in one function a single mutex wrapped around these sections seems to suffice. The performance gain was quite substantial. Obviously this optimisation would not work on single core CPUs.
Another improvement is the implementation of the Kajiya and Kay lighting model. This lighting model works on tangents, treating the hair as an infinitely thin cylinder. The end result is a much more distributed specular highlight and better lighting in general .




