Render elements allow renderers to output to separate bitmaps portions of the final shaded image so that they can be manipulated/composited at a later time, without re-rendering.
Render elements are specific to a given renderer. 3ds Max defines both a general interface that all render elements (IRenderElement
) must support & an interface specific to elements supporting the max default renderer. Part of the general interface allows the system to figure out which installed render elements belong to which renderer, & to only list those compatible elements.
3ds Max render elements are supported by code in each material. After shading, each active render element's IRenderElement::PostIllum()
method is called in turn. It is provided with;
Essentially, this is all of the information that is passed to 3ds Max Shaders, plus the shadowed or unshadowed component-wise output from the materials shading process. This means that each render element may in fact be a complete, alternate, special-purpose shader. This is intentional, of course, so that any wacky thing might be created. Most current render elements don't take advantage of this, tho, they merely process the component-wise output from the materials shading process, but the potential is very powerful.
3ds Max Render elements then store their computed shade in an extended ShadeOutput
class (imtl.h) that is part of the ShadeContext.
The ShadeOutput
has an array of element output values, one per element & each max render element is given an index into the array to use. The ShadeOutput
will follow the fragments being shaded all through the compositing process, so that transparency & partial coverage is properly resolved.
Atmosphere cannot be properly computed at shading time since the object may be covered by a transparent object, dividing the needed calculation into two: atmosphere from the eye to the transparent object, composited over atmosphere between the two objects & the final objects color. Hence there is a second, optional call to each render element after the atmosphere is computed. The general interface tells the system whether to apply atmosphere to the render elements color, does so if desired & calls the MaxRenderElement::PostAtmosphere()
method on the render element.
Finally, a last query on the general interface determines whether to apply the anti-aliasing filter when outputting the element to its bitmap, or merely blending with other elements in the pixel.