About
The Substance functions allow to import and handle Allegorithmic Substance assets into a BaseDocument . In a document they can be used with shaders and materials. The Substance functions are defined in the lib_substance.h
header file.
Access Assets
Substance assets store a reference to a Substance archive file (.sbsar) and the current value set of its parameters. These assets are stored in the BaseDocument .
while (substance != nullptr )
{
}
if (substances == nullptr )
for (
Int32 i = 0; i < substanceCount; ++i)
{
if (asset == nullptr )
}
Add Assets
A Substance asset can be imported using the Filename of a Substance archive file (.sbsar).
const Bool invalidSubstance = substance ==
nullptr ;
if (importFailure || invalidSubstance)
if (copySubstance == nullptr )
const String copyName = originalName +
" Copy" ;
Get Assets
A Substance asset can contain one or multiple graphs, input parameters and output bitmaps.
void * graph = nullptr ;
do
{
if (graph != nullptr )
{
void * input = nullptr ;
do
{
input =
GetSubstanceInput (substance, graph, input, inputID, descID, numberElements, type, inputName);
if (input != nullptr )
} while (input != nullptr );
void * output = nullptr ;
do
{
output =
GetSubstanceOutput (substance, graph, output, outputID, type, outputName,
nullptr );
if (output != nullptr )
} while (output != nullptr );
}
} while (graph != nullptr );
Materials and Shaders
Substance assets are used in shaders and are typically applied (but not limited) to materials:
if (material == nullptr )
const String materialName = substanceName +
" Material" ;
An example how to configure a Substance shader can be found on Substance Elements Manual .
Substance Preferences
These utility functions allow fast access to the most important Substance preferences.
Utility
Further utility functions are:
bool useSubstances = false ;
while (material != nullptr )
{
{
useSubstances = true ;
break ;
}
}
if (useSubstances)
Further Reading
BaseList2D * GetFirstSubstance(BaseDocument *const doc)
Definition: c4d_baselist.h:2144
C4DAtom * GetClone(COPYFLAGS flags, AliasTrans *trn)
Definition: c4d_baselist.h:1417
void * GetSubstanceInput(BaseList2D *const asset, void *const graph, void *const prevInput, UInt32 &inputUid, Int32 &firstId, Int32 &numElements, SUBSTANCE_INPUT_TYPE &type, String &name)
maxon::UInt32 UInt32
Definition: ge_sys_math.h:59
BaseList2D * GetNext()
Definition: c4d_baselist.h:2183
BaseMaterial * GetFirstMaterial(void)
BaseMaterial * CreateMaterial(BaseList2D *const asset, Int32 graphIndex, SUBSTANCE_MATERIAL_MODE mode)
Int32 GetCount() const
Definition: c4d_baselist.h:1619
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
void * GetSubstanceGraph(BaseList2D *const asset, void *const prevGraph, String &name)
SUBSTANCE_MATERIAL_MODE PrefsGetMaterialModeSetting()
SUBSTANCE_IMPORT_RESULT ImportSubstance(BaseDocument *const doc, const Filename &fn, SUBSTANCE_IMPORT_COPY ©File, Bool errPopup, Bool addUndo, Bool createMaterial, BaseList2D **assetPtr)
SUBSTANCE_OUTPUT_TYPE
Definition: lib_substance.h:314
Definition: c4d_string.h:38
void InsertMaterial(BaseMaterial *mat, BaseMaterial *pred=nullptr, Bool checknames=false)
void * GetSubstanceOutput(BaseList2D *const asset, void *const graph, void *const prevOutput, UInt32 &outputUid, SUBSTANCE_OUTPUT_TYPE &type, String &name, BaseBitmap **bmpPtr)
SUBSTANCE_IMPORT_RESULT
Definition: lib_substance.h:265
SUBSTANCE_MATERIAL_MODE
Definition: lib_substance.h:251
@ NO
Do not copy file to project directory (absolute file path).
Definition: c4d_baselist.h:1331
Bool MaterialUsesSubstance(BaseMaterial *const mat)
void SetName(const maxon::String &name)
Definition: c4d_baselist.h:2324
maxon::Int32 Int32
Definition: ge_sys_math.h:58
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:207
SUBSTANCE_INPUT_TYPE
Definition: lib_substance.h:291
Definition: ge_autoptr.h:36
Bool InsertLastSubstance(BaseDocument *const doc, BaseList2D *asset)
void GetSubstances(BaseDocument *const doc, AtomArray *arr, Bool onlySelected)
BaseMaterial * GetNext(void)
Definition: c4d_basematerial.h:60
maxon::Bool Bool
Definition: ge_sys_math.h:53
String GetName() const
Definition: c4d_baselist.h:2318
SUBSTANCE_IMPORT_COPY
Definition: lib_substance.h:279
Definition: c4d_basematerial.h:27
C4DAtom * GetIndex(Int32 idx) const
Definition: c4d_baselist.h:1634