Note that hair in version 3.7 has changed to accommodate full approximation specifications. From the Upgrading from mental ray 3.6 to 3.7 change notes:
The struct returned by mi_api_hair_begin() has changed. This means that the related shaders need to be recompiled, and slightly rewritten.Hair Approximation
Added approximation for hair. In addition to the old approximation syntax which directly specifies the number of approximating segments, it is now possible to specify adaptive length, distance, angle approximation including view-dependent approximations. Parametric approximations depending on the degree of the hair curves are supported as well.
Especially for curved hair and hair at higher viewing distance, the new approximation criterion allows to have high approximation resolution restricted to the area where needed. The lower number of hair segments result in reduced memory consumption and increase rendering speed.
In order to get benefit from curvature-dependent approximations, hair needs to be modelled appropriately with hair degree > 1.
The hair approximation can be specified on a hair object with the following syntax:
approximate hair <curve_approx>
with <curve_approx> being any curve approximation technique, for example:
approximate hair view length 3 distance 0.1 angle 5 0 7
In a geometry shader the approximation is no longer an integer, but a full approx structure.
For example, in hair_geo_4v.c, we could change it to:
Note in the commented out code the use of a view dependent approximation with a length specification.Code:mi_api_incremental(miTRUE); miaux_define_hair_object(p->name, hair_geo_4v_bbox, p, NULL, NULL); hair_list = mi_api_hair_begin(); hair_list->degree = p->degree; miAPPROX_DEFAULT(hair_list->approx); hair_list->approx.cnst[miCNST_UPARAM] = (miScalar)p->approximation / (miScalar)p->degree; /* miAPPROX_FINE_DEFAULT(hair_list->approx); */ /* hair_list->approx.cnst[miCNST_LENGTH] = (miScalar)p->approximation; */ mi_api_hair_info(0, 'r', 1);
miAPPROX_FINE_DEFAULT fills in the equivalent of fine view length 0.25
miAPPROX_DEFAULT fills in a parametric approximation
In the manual, see Geometry Shaders->Geometry Shader Data Structures->Approximations for more details on the miApprox struct and these macros.