Ce patch permet de spécifier une fonction au lieu d'un float ou d'une couleur pour les paramètres finish
d'une texture. Les paramètres du finish
sont alors évalués à chaque point d'intersection, lors du rendu.
Dans la partie finish
d'une texture, au lieu d'un float ou d'une couleur on peut donner soit un identificateur de fonction, soit une déclaration de fonction. Attention il faut que la fonction retourne une valeur/une couleur qui corresponde au type du paramètre.
finish { [uv_mapping] ambient COLOR | VECTOR_FUNCTION_IDENT | VECTOR_FUNCTION diffuse Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION brilliance Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION phong Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION phong_size Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION specular Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION roughness Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION (Cf. warning) reflection COLOR | VECTOR_FUNCTION_IDENT | VECTOR_FUNCTION reflection { Color_Reflection_Min | VECTOR_FUNCTION_IDENT | VECTOR_FUNCTION , Color_Reflection_Max | VECTOR_FUNCTION_IDENT | VECTOR_FUNCTION falloff FLOAT_FALLOFF | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION exponent FLOAT_EXPONENT | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION (Cf. warning) } irid { Irid_Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION thickness Amount | FLOAT_FUNCTION_IDENT | FLOAT_FUNCTION } }
Si uv_mapping
est spécifié dans le bloc finish
, l'évaluation se fait après passage des coordonnées en u,v.
roughness
et exponent
il faut une fonction qui retourne 1/roughness
et 1/exponent
.
#declare fct = function { pigment { checker color rgb 0 color rgb 1 scale .1 } } sphere { ... finish { uv_mapping reflection fct } cone { ... finish { diffuse function {y} } }
Look for #ifdef FINISH_MAPS_PATCH in sources
The patch adds 3 new members to the FINISH struct : a number which indicates the number of evaluations required, a boolean to know if we must use uv_mapping, and a pointer to an array of a structure with an offset (offset to the member of the finish struct to modify) and a FUNCTION_PTR. This array is filled during the parsing, and sorted by function (so that after, if the same function is used by more than one member of finish, it is only evaluated once).
Possible improvements/problems