» Back to Documentation

 


As you might have read before in the basics of hair optimization Ox hair object that is passed through the pipeline has a controllable number of information that can get attached to it. Here we will go into a little more detail of exactly what this information is, what it affects, and what are some of the best ways to use it for balancing the speed versus memory usage issue.

They key to achieving the fastest results is to balance out the cpu usage with the memory usage. Many of the commonly used computations can be precomputed and stored along with the hair so that any modifiers that use this hair later on don't have to precompute this data. There is also extra information that can get attached to hair so that modifiers placed above in the stack can use it.

The five basic info types that can be attached to hair are: root topology data, root transform matrix, surface dependency info, guide dependency info. Some of this data may never be used by modifiers so it isn't required to be included with hair by hair state converter. Here are short descriptions of each attached data and what it is used for:


Root topology data:

Root topology can be thought of as faces in a mesh. Its main function is to determine which vertices form which guides. This data is only required when not all strands in the hair object have the same number of segments. Otherwise it is safe to assume that each consecutive hair strand will use the same number of vertices and thus no root topology is required, which can save some space in final dense hair model.


Root transform matrix:

This data takes up the most space and is usually not needed for basic strand operations. Root TM much like object TM for any node in the scene transforms every strand in the hair object into object coordinates. Therefore if root TMs are present all vertices are located not in object space but rather in their own local space. This can be very helpful to some modifiers like surface comb because all strands can be simply combed along their own XYZ coordinates and rootTMs will transformed them to be combed relative to mesh surface. Root TMs are also needed for strand instancing. The best idea is to do all the room TM-dependant operations in guide state and once the state converts into hair not to attach root TM data since it alone can take more memory than hair vertices.

When root TMs aren't present all the vertices appear in object space and thus can be processed more quickly by the raytracer. If they aren't present and some modifier requests root transform, it is generated on the fly from surface data info which is slower but still produces same results. If surface info isn't present then the tangent of the first hair segment is used.

If you specify to use root TMs and root topology is present then vertex lookup tables are also generated automatically. Vertex LTs take up additional (minimal) space but are required to make hair deformable. Note that these LTs are only generated if both rootTM and topology data is present, otherwise they're not required and space is conserved.


Surface dependence data:

Ox hair structures are designed to be dependant on two externally defined objects- mesh and guides. While guides primarily define the shape of hair distribution mesh is used to retrieve useful data such as surface normals, vertex data, integrity, UVW coordinates and many other tasks. Surface dependence data specified exactly where every strand lies on an object and how it is affected when the object changes/deforms. Dense hair isn't required to carry this data and it isn't really trivial in many cases. You have to remember a couple of things- you will have to attach surface data if you want to use maps on per-strand level, and/or if you want to export/cache hair and attach it to the same mesh object later on.

If surface dependence data isn't attached and UV coordinates for a strand are requested then Ox will use guide dependence data to find out UV coordinates of closest guide. If guide data isn't available then world coordinates of strand's root are used as UV.


Guide dependence data:

Ox hair has a huge dependence on guides that form it. At some point this dependence isn't required anymore and hair can continue on functioning independently. Guide dependence data specifies which guide each strand in a hair object depends on and how much it depends on it. This data is required if you use guide channels or if you decide to inherit guide data such as UV and surface info isn't available. Generally guide data takes more memory than surface data and in most cases when channels aren't used it can be ignored. The best idea is to do all of the vital changes in guide state and once converted to hair not to include this data. However in some cases it is required that guide data is present in dense state.

These four optional data types can be attached to hair at will to allow it to inherit certain data from mesh, guides, and also to optionally precompute data which might be needed later on, such as root transform. Guides are required to have all of the above types except guide dependency, which is optional. Since guides require relatively small amount of memory it is better to store all of the information so it can be accessed quickly and then inherited by denser hair.


Here are some pointers to the usage of optional info with hair:

- If you are using channels attach guide dependency info
- If you have a very dense hair model such as animal fur or full-body hair do not attach root transform matrix. It can be computed later from surface info if needed.
- If you want to use maps you do not have to always attach surface dependency info. If you do not care about the sampling resolution of hair, all the UV info can be inherited from guides.
- In most cases you will not need to attach root topology, hence option is off by default. This option is reserved for hair that doesn't have same number of segments per-strand and thus is often used with guides.
- When you instance strands root transform is always required. Transform matrix alone take up same amount of memory required to store four hair vertices. Therefore if you are using instancing to conserve memory it will only work with longer hair where number of vertices is high and well above 10. Therefore instancing is useless when it comes to short fur since fur shape can be easily approximated with a small number of control vertices.


 

See also: Optimizing hair pipeline: Basics, Optimizing hair pipeline: Optional data, Optimizing hair pipeline: Rendering