It is possible to create a variety of special effects using layered textures. A layered texture consists of several textures that are partially transparent and are laid one on top of the other to create a more complex texture. The different texture layers show through the transparent portions to create the appearance of one texture that is a combination of several textures.
You create layered textures by listing two or more textures one right after the other. The last texture listed will be the top layer, the first one listed will be the bottom layer. All textures in a layered texture other than the bottom layer should have some transparency. For example:
object { My_Object texture {T1} // the bottom layer texture {T2} // a semi-transparent layer texture {T3} // the top semi-transparent layer }
In this example T2 shows only where T3 is transparent and T1 shows only where T2 and T3 are transparent.
The color of underlying layers is filtered by upper layers but the results do not look exactly like a series of transparent surfaces. If you had a stack of surfaces with the textures applied to each, the light would be filtered twice: once on the way in as the lower layers are illuminated by filtered light and once on the way out. Layered textures do not filter the illumination on the way in. Other parts of the lighting calculations work differently as well. The results look great and allow for fantastic looking textures but they are simply different from multiple surfaces. See stones.inc
in the standard include files directory for some magnificent layered textures.
Note layered textures must use the texture
wrapped around any pigment, normal or finish statements. Do not use multiple pigment, normal or finish statements without putting them inside the texture statement.
Layered textures may be declared. For example
#declare Layered_Examp = texture {T1} texture {T2} texture {T3}
may be invoked as follows:
object { My_Object texture { Layer_Examp // Any pigment, normal or finish here // modifies the bottom layer only. } }
If you wish to use a layered texture in a block pattern, such as checker
, hexagon
, or brick
, or in a material_map
, you must declare it first and then reference it inside a single texture statement. A patterned texture cannot be used as a layer in a layered texture however you may use layered textures as any of the textures contained within a patterned texture.