|home||<< prev||next >>||contents|
Hair support was introduced in mental ray 3.1. Rendering hair is a difficult problem for triangle rendering because the number of hairs is typically very large (hundreds of thousands or millions), and each hair has a very large bounding box that it fills poorly. For this reason, a new hair primitive was introduced that avoids this problem, and also has a highly optimized storage format that avoids the storage overhead for triangle hairs.
Here is an example:
object "object_name" [ visible [on|off] ] [ shadow [on|off] ] [ shadowmap [on|off] ] [ trace [on|off] ] [ reflection [mode] ]3.4 [ refraction [mode] ]3.4 [ transparency [mode] ]3.4 [ select [on|off] ] [ tagged [on|off] ] [ caustic [on|off] ] [ globillum [on|off] ] [ caustic [mode] ] [ globillum [mode] ] [ finalgather [mode] ]3.4 [ box [min_x min_y min_z max_x max_y max_z] ] [ motion box [min_x min_y min_z max_x max_y max_z] ] [ max displace value ] [ samples min max ] [ data null|"data_name" ] [ tag label_numberint ] hair [ material "material_name" ] [ radius radius ] [ approximate segments ] [ degree degree ] [ max size size ] [ max depth depth ] [ hair n ] [ hair m hm ] [ hair t ht ] [ hair u hu ] [ hair radius ] [ vertex n ] [ vertex m vm ] [ vertex t vt ] [ vertex u vu ] [ vertex radius ] scalar [ nscalars ] scalar list hair [ nhairs ] hair offset list end hair end object
The object header is similar to the headers for all other geometry types, but the standard group...end group block is replaced with hair...end hair. This block begins with a common header, followed by a scalar list, followed by a hair list. The header has the following optional statements:
It does not make sense to specify hair n if there is also a vertex hair because all hair normals will be overridden. Similarly, if vertex radii are used, no hair radii (or the global radius) should be present. If any normals are specified, the hairs are not intersected like cylinders but like oriented flat ribbons.
The scalar list defines a sequence of hairs. Each hair consists of a certain number of scalars that describe the entire hair, followed by another number of scalars that describe each vertex of the hair. The layout of these sequences of scalars is identical for all hairs, except that each hair may have a different number of vertices. It is not possible to have one hair with three texture scalars and another with two, for example. Here is the exact sequence of scalars for a single hair:
All vertices begin with three scalars for the location. The order of the other vertex scalars, and the order of the header scalars, is determined by the order of hair and vertex statements. The lists above correspond to the syntax listing at the beginning of this section: first n, then m, then t, then u, then radius.
Each hair has only one header but multiple vertices. As described above, the number of vertices must be , where segments may be different for each hair. This number is not encoded in the hair but in the separate hair list. Note that hairs do not use texture vectors like polygons and free-form surfaces but texture scalars. It's up to the shader to interpret as a list of scalars, and properly use them in groups of one, two, three, or whatever is needed. This makes it possible to avoid the third null component if only two-component UV textures are needed, for example, which can save a lot of memory because hair objects tend to have a very large number of vertices, probably millions.
The hair list specifies where in the scalar list each hair begins, by offset in the scalar list such that 0 is the first scalar, 1 is the second scalar, and so on. At the end of this offset list, one extra offset specifies the last scalar plus one, where the next hair would begin if there were another one. If all scalars are used (which is normally the case), the first offset is 0 and the extra one at the end equals the number of scalars. Here is a simple example for a hair object:
object "hair1" visible trace shadow tag 1 hair material "mtl" radius 0.3 degree 1 hair t 2 vertex t 1 scalar [ 42 ] 11 22 0.0 0.0 0.0 1111 0.0 1.0 0.0 1112 1.0 1.0 0.0 1113 33 44 0.0 0.0 0.0 1114 0.0 -1.0 0.0 1115 -1.0 -1.0 0.0 1116 55 66 0.0 0.0 0.0 1117 0.0 -1.0 0.0 1118 -1.0 -1.0 0.0 1119 hair [ 4 ] 0 14 28 42 end hair end object
This example consists of three hairs, each with three vertices. The header of each hair consists of two texture scalars (11 22, 33 44, and 55 66, respectively). Each vertex consists of four scalars, three for the location in object space and one more for a vertex texture. The shader will receive three texture scalars, two from the hair and one more from the vertices. The former are copied from the hair that was hit, and the latter is interpolated from the nearest two vertices. They are stored in as if it were a scalar array, header texture scalars first, so the two hair texture scalars end up in tex_list.x and tex_list.y, and the vertex texture scalar ends up in tex_list.z. It is best to re-cast tex_list to a miScalar pointer in the hair shader.
Hair objects may use the same material shaders as any other object, but often special hair material shaders are used because although hair may be a cylinder, it is too thin for properly resolving the upper and lower edge and the diffuse terminator and the highlight. There is a simplified hair illumination shader in the base shader library, mib_illum_hair that implements a much more effective hair shading model.
|home||<< prev||next >>||contents|
Copyright © 1986-2006 by mental images GmbH
Return to Autodesk Index