Org:Institute/Open projects/Durian/HairNotes

提供: wiki
移動先: 案内検索

Notes on Hair Issues

Rendering and simulating hair has been quite problematic for Durian, and we didn't succeed solving these problems well. Here are some notes on how we worked around problems, and what should be improved in the future.

Particle System

The hair particle system was created on a separate mesh. This mesh is a copy of the sintel model, with all faces but the ones that have hair on them removed, and slightly pushed inwards to ensure hairs always start under the surface. This mesh is deformed by the same armature as regular mesh.

There are approximately 300 parent hairs, with 600 child hairs per parent, so about 180k in total. The hair particles where edited in particle edit mode to achieve the desired shape.

Lighting

Hair is lit completely separate from everything else. This adds extra work, but the lack of better shaders and lighting algorithms requires this. The hair material has a light group assigned with Exclusive enabled to do this.

This works if the model is local, but when it is linked in we want to change the lights that affect the hair. For this the Local option is enabled. It means a group of lights can created locally with the same name as the group in sintel.blend, and if the group has the same name as the group set in the original sintel file, it will be used instead of the linked group.

Indirect lighting is disabled for the hair (ambient set to 0.0), this has to be compensated manually with these lights.

For Future Projects

A better hair shader would be useful. As far as I can see the current hair shader is not broken in what it tries to do, but is difficult to light. This is because it is mostly a purely specular shader, and there is not suitable normal as with regular surface shading. Still, a shader like the one by Marscher would be useful.

A diffuse component would be useful, to light the hair more as if it was a regular surface. In reality any diffuseness is caused by multiple scattering, which can be simulated using a technique like e.g. Dual Scattering. A simpler solution is the Pixar trick to compute surface-like normals by rasterizing the hair in a volume and computing normals from that.

Shadows

For self-shadowing, spot lamps with classical-halfway or deep shadow maps are used. Typically there are about 3 such spot lamps in the hair light group.

To let the hair cast shadows on the head when using raytraced shadows or e.g. environment lighting, a second hair particle system exists. This is an exact copy of the original system, but with fewer child particles and thicker strands. These can then be raytraced reasonably efficient without too much memory usage. This particle system is only enabled for shadowing, and so is not visible directly in the render.

For Future Projects

Raytracing of strands should be implemented so we don't need to do this thick hair trick. How that will work out in performance I'm not sure, if it's too slow it could still be possible to add native support for raytracing lower resolution hair instead of having to manually create a second particle system.

Simulation

Hair simulation uses the hair dynamics functionality.

For collision we use a different mesh than the real model, which is simpler, and as a result quicker and more stable. Especially important is to avoid the hairs intersecting the mesh in the rest pose.

Hairs are weighted in particle mode, and this affects the stiffness. Basically there is a falloff from the root of the hair which has very high weight and so is very stiff, to very low values at the tip of the hair. High weights near the root are necessary to keep the hair from losing it's overall shape.

Pin and bending stiffness in the hair dynamics works to give the hair some resistance to bending, but can not prevent the hair from getting completely pulled down from gravity, increasing these will either dampen out all interesting motion or cause instability. As a workaround there are settings to fix bending slightly after the simulation, by bending the parent hairs back. We use settings offset=4, factor=0.66 and falloff=1.0 for this. This functionality does not work great in many cases but is better than nothing.

For Future Projects

A better hair simulator would be very welcome. This could be either done by improving the existing one or adding a completely new simulator. In any case, the current solver is not reliable and jittery. In addition bending forces do not work well, something like angular springs could be useful.

Most important topics to solve seems to be collision and preserving the hair shape. Hair is almost constantly in collision with the head and so we need a very stable collision response that does not flicker.

For preserving hair shape better bending forces would help, though it may not be sufficient. Part of the problem is that the manually modelled hair shape isn't the result of a physics simulation, and so is not really correct as a rest position.

Point Cache

Due to bugs and instabilities in the hair dynamics, hair will often flicker or behave strangely. We run the hair solver with about 10 different settings on all shots, and write out the point caches and an opengl render of the result. Then we pick the best result for each shot.

For each shot, we have a python script that runs on opening the .blend file. This script contains the settings for all shots and applies them to the particle system and sets the point cache directories to a unique directory.

This is necessary because the particle system is linked in and no proxy system exists currently for such physics settings, however python can write properties in linked datablocks.

For Future Projects

A proper proxy system should exist for physics settings and point caches. For the physics settings a generic type of proxy system to override any setting in a linked datablock would be useful, though a more specific solution could work as well.

Proxy support for point caches needs specific changes, so that a local copy of the pointcache can be stored in the scene, and the right paths are used to store the disk cache locally instead of in the cache for sintel.blend.

Furthermore, command line options to bake point caches would be useful, similar to the option to render from a .blend file, a background bake could be added.

Example File

http://durian.blender.org/wp-content/uploads/05.8b.blend