Here are the helper shaders currently implemented in the layering package:
Mixing other shaders with layering shader is not currently recommended, since it will not use shared light lists, and be able to use LPE multi-pass control, among many things. It may be of some use in the future. All shaders participating in the layering shade tree (i.e. any shader plugged into mila_layer or mila_mix) must be able to participate properly in internal layering communications for passing component weights and other data.
declare shader color "mila_adapter" ( color "input", array struct "passes" { string "path", color "output", boolean "comp" } ) version 1 apply texture end declare
Though not recommended, to use this shader, plug in some other non-layering shader into it's inputs. It will (as well as possible) turn the shader into something that works with the layering shader system.
A couple of rules must be followed:
The mia material uses glossiness as an input parameter. This small helper shader simply inverts glossiness to make roughness used by mila_glossy_* shaders.
declare shader scalar "mila_get_roughness" ( scalar "glossiness" ) apply texture version 1 end declare
Many older mental ray bump mapping shaders simply modify the normal - the mila_layer and mila_mix shaders require the modified normal as a vector input.
This small helper shader simply calls some shader (generally such a bump shader), and then returns the modified normal.
declare shader vector "mila_get_normal" ( shader "shader" ) apply texture version 1 end declare
To use this shader with the 3ds max DCC application, use the shader max_Bump (supplied with 3ds max) into which the actual texture shaders (e.g. max_Bitmap) are plugged.
Example:
max_Bitmap => max_Bump.Map => mila_get_normal.shader => mila_layer.components[x].bump
declare shader struct { vector "normal", color "color" } "mila_flakes_adapter" ( color "tint", shader "flakeshader" ) apply texture version 1 end declare
This shader exists solely to interface with the mi_flakes_bump shader from the paint library. That shader has a very special behavior where it takes a color, modifies it, and returns the color and modifies the normal in a single operation.
This helper shader takes the given color and calls the flakeshader (which must be an instance of mi_flakes_bump and returns the modified color and the normal as separate outputs, to be connected to the appropriate inputs of the layering shaders.
This shader assists in car paint component combinations to simulate flakes effecting both a normal change and a visibility factor.
See the car paint examples here for a use case.
declare shader struct { vector "normal", scalar "visibility" } "mila_bump_flakes" ( scalar "weight" default 1.0, scalar "density" default 0.5, scalar "perturbation" default 0.8, scalar "scale" default 0.2, integer "type" default 0, integer "cell_style" default 0, #: enum "edgy:circular" scalar "circle_size" default 0.5 ) apply texture version 4 end declare
This shader shifts normals for the separate components of the base hair: Primary Reflection (R), Transmission (TT), Secondary Reflection (TRT), Secondary Reflection Glint Right and Left lobes(TRT Glint R/L).
declare shader vector "mila_shift_normal" ( integer "mode" default 0, #: enum "hair_R:hair_TT:hair_TRT:hair_TRT_glint_R:hair_TRT_glint_L" scalar "u_offset" default 0.0, scalar "v_offset" default 1.0 ) version 1 apply texture end declare
This shader shifts normals at the most base level to change from ribbon to cylindrical hair shaped geometry. In mental ray, hair is modeled as ribbons facing the camera / eye. This is a method to emulate cylindrical geometry by changing the normal. Not necessary if using fully modeled geometry for hair tubes.
declare shader vector "mila_hair_base_normal" ( ) version 1 apply texture end declare
This shader takes square root of color, useful for hair color absorption, of half distance.
declare shader color "mila_color_sqrt" ( color "color" ) version 1 apply texture end declare
This shader creates hair tint color from base and tip colors.
declare shader color "mila_hair_color" ( color "base_color" default 0.3 0.3 0.2 1, scalar "base_noise" default 0, color "tip_color" default 0.6 0.6 0.4 1, scalar "tip_noise" default 0 ) version 1 apply texture end declare
This shader creates hair tint scalar from base and tip scalars.
declare shader scalar "mila_hair_scalar" ( scalar "base_scalar" default 0., scalar "base_noise" default 0, scalar "tip_scalar" default 1, scalar "tip_noise" default 0 ) version 1 apply texture end declare
This shader makes a vector from a scalar, repeating the scalar value to x, y, z channels of vector.
declare shader vector "mila_scalar_to_vector" ( scalar "scale" ) version 1 apply texture end declare
This shader serves in place of physical light, as it also adds functionality for texture mapping, as well as splitting color and intensity for typical light integrations.
declare shader color "mila_light" ( color "color", scalar "intensity", scalar "cone", scalar "threshold",# accuracy threshold for optimization scalar "cos_exp" # cosine exponent (disc&rectangle) ) version 1 apply light end declare