Layered Material (TGorillaLayeredMaterialSource)

The TGorillaLayeredMaterialSource is a container of multiple sub materials. It works like a stack, where one material is rendered above another. The following schema visualizes this idea:

It is important that those sub materials do not clear the context, otherwise it will produce unexpected behaviour!

If the materials collection is empty, Gorilla3D will render the complete buffer with black color.

To setup sub-materials, simply add those to the material collection:

var LLayMat : TGorillaLayeredMaterialSource;
    LSubMat1 : TGorillaNormalMapMaterialSource;
    LSubMat2 : TGorillaPhongMaterialSource;
    LSubMatEntry : TGorillaLayeredMaterialItem;
[...]
 
// create the layered material source
LLayMat := TGorillaLayeredMaterialSource.Create(FGorilla);
LLayMat.Parent := FGorilla;
 
// create sub-material #1
LSubMat1 := TGorillaNormalMapMaterialSource.Create(FGorilla);
LSubMat1.Parent := FGorilla;
 
// add sub-material #1
LSubMatEntry := LLayMat.Materials.Add();
LSubMatEntry.Material := LSubMat1;
 
// create sub-material #2
LSubMat2 := TGorillaPhongMaterialSource.Create(FGorilla);
LSubMat2.Parent := FGorilla;
 
// add sub-material #2
LSubMatEntry := LLayMat.Materials.Add();
LSubMatEntry.Material := LSubMat2;