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)
const Int32 substanceCount = substances->GetCount();
for (
Int32 i = 0;
i < substanceCount; ++
i)
{
if (asset == nullptr)
}
Py_ssize_t i
Definition: abstract.h:645
Definition: ge_autoptr.h:37
Definition: c4d_baselist.h:2376
String GetName() const
Definition: c4d_baselist.h:2543
BaseList2D * GetNext()
Definition: c4d_baselist.h:2414
Definition: c4d_baselist.h:1520
maxon::Int32 Int32
Definition: ge_sys_math.h:56
#define atom
Definition: graminit.h:72
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
void GetSubstances(BaseDocument *const doc, AtomArray *arr, Bool onlySelected)
BaseList2D * GetFirstSubstance(BaseDocument *const doc)
const char * doc
Definition: pyerrors.h:226
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";
PyCompilerFlags const char * filename
Definition: ast.h:15
void SetName(const maxon::String &name, Bool setDirty=true)
Definition: c4d_baselist.h:2549
C4DAtom * GetClone(COPYFLAGS flags, AliasTrans *trn) const
Definition: c4d_baselist.h:1605
Definition: c4d_string.h:41
Py_UCS4 * res
Definition: unicodeobject.h:1113
maxon::Bool Bool
Definition: ge_sys_math.h:51
SUBSTANCE_IMPORT_COPY
Definition: lib_substance.h:280
@ NO
Do not copy file to project directory (absolute file path).
SUBSTANCE_IMPORT_RESULT
Definition: lib_substance.h:266
SUBSTANCE_IMPORT_RESULT ImportSubstance(BaseDocument *const doc, const Filename &fn, SUBSTANCE_IMPORT_COPY ©File, Bool errPopup, Bool addUndo, Bool createMaterial, BaseList2D **assetPtr)
Bool InsertLastSubstance(BaseDocument *const doc, BaseList2D *asset)
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
{
if (input != nullptr)
} while (input != nullptr);
do
{
}
} while (graph != nullptr);
const char const char * name
Definition: abstract.h:195
Py_ssize_t char * output
Definition: unicodeobject.h:985
maxon::UInt32 UInt32
Definition: ge_sys_math.h:57
SUBSTANCE_INPUT_TYPE
Definition: lib_substance.h:292
SUBSTANCE_OUTPUT_TYPE
Definition: lib_substance.h:315
void * GetSubstanceInput(BaseList2D *const asset, void *const graph, void *const prevInput, UInt32 &inputUid, Int32 &firstId, Int32 &numElements, SUBSTANCE_INPUT_TYPE &type, String &name)
void * GetSubstanceOutput(BaseList2D *const asset, void *const graph, void *const prevOutput, UInt32 &outputUid, SUBSTANCE_OUTPUT_TYPE &type, String &name, BaseBitmap **bmpPtr)
void * GetSubstanceGraph(BaseList2D *const asset, void *const prevGraph, String &name)
PyObject ** type
Definition: pycore_pyerrors.h:34
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";
doc->InsertMaterial(material);
Definition: c4d_basematerial.h:28
const wchar_t * mode
Definition: fileutils.h:96
SUBSTANCE_MATERIAL_MODE
Definition: lib_substance.h:252
SUBSTANCE_MATERIAL_MODE PrefsGetMaterialModeSetting()
BaseMaterial * CreateMaterial(BaseList2D *const asset, Int32 graphIndex, SUBSTANCE_MATERIAL_MODE mode)
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)
BaseMaterial * GetNext()
Definition: c4d_basematerial.h:60
Bool MaterialUsesSubstance(BaseMaterial *const mat)
Further Reading