Understanding Layering of Shading (post in progress)
25.5.2011 Started document with initial outline, much to be done
Introduction
Layering shaders inevitably means to understand what a shader actually does, or to be more specific what it is the shader your layering does. Alternatively its a symptom of not understanding system that you use to build your shaders in. Since both of these issues are entangled together, it is likely that both accounts come into question.
Luckily you only need to have a very fundamental overview on how shaders work to get things done. Freedom to do whatever one likes in shading unfortunately means no single approach works for all shaders. As a consequence its impossible to make one nice easy GUI for them all, that can satisfy all criteria.
Brief Overview Into Shading
Shaders are are basically functions that get called when a surface point gets marked for calculation either by a ray or by some other means such as scene init, scene population etc etc. The rendering engine take scare of calling this function and provides the function with data derived form the shading context.
The actual shading pipeline of a modern render can be quite complex with many different phases for different purposes. The term shader has become a catch all terminology for all rendering engine API events as well as any collection thereof, overloading the term. So a shader could be called during scene init to build actual new geometry in the scene, or during triangulation to offset the surface in question. Keeping things simple, for the remainder of this document it is assumed that shading deals with coloring of surface pixel unless otherwise stated. Additionally that a shader is the result of one shading network and a individual shading node is called just for brevity a node.
...
Some good reference for furthering ones understanding can be found in 2002 siggraph course 16 paper RenderMan in Production, especially the first section 'Lore of the TDs' by Tony Apodaca will fill in the basic concepts quite well no matter what software you use.
Understanding the Phenomena Your Trying to Model
para
Doing the Same Thing Without Layering
para
Almost Anything can be Used as a Layering Function
Theres no right way to do things, hence any function you can conceive can and should be considered for the job, as long as you think about the resulting physical implications and they match your requirement its a acceptable way to go. Please remember that the things we deal with are engineering level approximations good enough is actually perfect for our purposes. There's no room for puritanism, we just don't have the horsepower required to work like the reality does, does not mean we cant strive towards it tough.
Because light is by nature additive just adding the values to the other shader is a good solution in many cases. Indeed this is what happens inside many of the mayas native shaders, which all are basically a lambertian shader + a flavor of specular calculation.
Overview of Basic Cases
para
Anatomy of a Complex case
para
Conclusion
para