The Substance library contains everything needed to control the Substance Engine integration in Cinema 4D. Main topics are:
Importing Substance Assets:
Auto-creating basic material from a Substance:
Iterate over all graphs, inputs and outputs of a Substance:
Changing Substance input parameters:
This basically works the same as with every other NodeData based entity in Cinema 4D, via SetParameter().
Chapter Substance shader and its parameters:
The Substance shader has two parameters, SUBSTANCESHADER_ASSET and SUBSTANCESHADER_CHANNEL.
Groups | |
| SUBSTANCE_IMPORT_COPY | |
| SUBSTANCE_IMPORT_RESULT | |
| SUBSTANCE_INPUT_TYPE | |
| SUBSTANCE_MATERIAL_MODE | |
| SUBSTANCE_OUTPUT_TYPE | |
| Substance Command IDs | |
| Substance Plugin IDs | |
Classes | |
| struct | SubstanceShdGetBitmap |
Create | |
| SUBSTANCE_IMPORT_RESULT | ImportSubstance (BaseDocument *const doc, const Filename &fn, SUBSTANCE_IMPORT_COPY ©File, Bool errPopup, Bool addUndo, Bool createMaterial, BaseList2D **assetPtr) |
| BaseMaterial * | CreateMaterial (BaseList2D *const asset, Int32 graphIndex, SUBSTANCE_MATERIAL_MODE mode) |
| BaseShader * | CreateSubstanceShader (BaseList2D *const asset) |
| Bool | AssignChannelToMaterial (BaseList2D *const asset, Material *const c4dMaterial, Int32 channelId, Int32 outputUid, Bool addUndo) |
Get and Insert | |
| BaseList2D * | GetFirstSubstance (BaseDocument *const doc) |
| void | GetSubstances (BaseDocument *const doc, AtomArray *arr, Bool onlySelected) |
| Bool | InsertLastSubstance (BaseDocument *const doc, BaseList2D *asset) |
Graphs, Inputs, Outputs | |
| void * | GetSubstanceGraph (BaseList2D *const asset, void *const prevGraph, String &name) |
| 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) |
Preferences | |
| SUBSTANCE_MATERIAL_MODE | PrefsGetMaterialModeSetting () |
| Int32 | PrefsGetPreviewSetting () |
Misc | |
| Bool | MaterialUsesSubstance (BaseMaterial *const mat) |
| BaseBitmap * | GetSubstanceMosaicPreview (BaseList2D *const asset, Int32 w, Int32 h) |
Private | |
| void | UpdateImageInputPaths (BaseList2D *const asset, String &path) |
| void | CloneReferencedSubstances (BaseDocument *const doc, BaseShader *const shd, BaseDocument *const ddoc, BaseShader *const dshd) |
| void | CloneReferencedSubstancesObject (BaseDocument *const docSrc, BaseObject *const opSrc, BaseDocument *const docDst, BaseObject *const opDst) |
| void | InsertSubstancePreviewScene (BaseDocument *const doc, BaseList2D *const asset) |
| const BaseBitmap * | GetContentBrowserOverlay () |
| SUBSTANCE_IMPORT_RESULT ImportSubstance | ( | BaseDocument *const | doc, |
| const Filename & | fn, | ||
| SUBSTANCE_IMPORT_COPY & | copyFile, | ||
| Bool | errPopup, | ||
| Bool | addUndo, | ||
| Bool | createMaterial, | ||
| BaseList2D ** | assetPtr | ||
| ) |
Imports a Substance Asset file (.sbsar) into doc.
| [in] | doc | The document to import into. |
| [in] | fn | The Substance Asset file. |
| [in,out] | copyFile | The copy file flag: SUBSTANCE_IMPORT_COPY. Determines if Substance Asset files are copied into the project folder (and therefore referenced with relative path). If set to SUBSTANCE_IMPORT_COPY::ASK, user's choice will be returned. Note: When set to SUBSTANCE_IMPORT_COPY::ASK, the function obviously has to be called in a context, where user interaction is allowed. |
| [in] | errPopup | If set to true, problems will be communicated to the user with a message requester. Note: When set to true, the function obviously has to be called in a context, where user interaction is allowed. |
| [in] | addUndo | If set to true, an undo step will be added for the import. Caller has to care for the surrounding BaseDocument::StartUndo() and BaseDocument::EndUndo() calls. |
| [in] | createMaterial | Set to true, to have a material created based on the configuration in preferences. Set to false, to suppress any creation of materials. |
| [in,out] | assetPtr | A pointer to a Substance asset pointer. If not nullptr, the pointer to the imported Substance Asset will be returned here. |
| BaseMaterial* CreateMaterial | ( | BaseList2D *const | asset, |
| Int32 | graphIndex, | ||
| SUBSTANCE_MATERIAL_MODE | mode | ||
| ) |
Creates a Cinema 4D standard material from asset.
| [in] | asset | The Substance asset. |
| [in] | graphIndex | The index of the graph to use (for multi-graph Substances). |
| [in] | mode | The material creation mode: SUBSTANCE_MATERIAL_MODE |
| BaseShader* CreateSubstanceShader | ( | BaseList2D *const | asset | ) |
Creates a Substance shader linked to asset.
| [in] | asset | The Substance asset (may be nullptr). |
| Bool AssignChannelToMaterial | ( | BaseList2D *const | asset, |
| Material *const | c4dMaterial, | ||
| Int32 | channelId, | ||
| Int32 | outputUid, | ||
| Bool | addUndo | ||
| ) |
Creates a Substance shader, links it to asset, sets the Substance output to outputUid and assigns the shader to channelId of c4dMaterial.
| [in] | asset | The Substance asset, the pointed Substance asset needs to be part of the document. |
| [in] | c4dMaterial | The Material. |
| [in] | channelId | The channel ID: CHANNEL |
| [in] | outputUid | The unique ID of the Substance output to use. |
| [in] | addUndo | If set to true, an undo step will be added for the import. Caller has to care for the surrounding BaseDocument::StartUndo() and BaseDocument::EndUndo() calls. |
| BaseList2D* GetFirstSubstance | ( | BaseDocument *const | doc | ) |
Retrieves a pointer to the first Substance asset in doc.
| [in] | doc | The document. |
| void GetSubstances | ( | BaseDocument *const | doc, |
| AtomArray * | arr, | ||
| Bool | onlySelected | ||
| ) |
Retrieves all (or only selected) substances assets doc.
| [in] | doc | The document. |
| [in] | arr | The AtomArray to fill. The caller owns the pointed array. |
| [in] | onlySelected | Set to true to get only selected Substance assets. |
| Bool InsertLastSubstance | ( | BaseDocument *const | doc, |
| BaseList2D * | asset | ||
| ) |
Inserts asset into doc (as last element).
| [in] | doc | The document. |
| [in] | asset | The Substance asset. On success Cinema 4D takes over the ownership of the pointed Substance asset. |
| void* GetSubstanceGraph | ( | BaseList2D *const | asset, |
| void *const | prevGraph, | ||
| String & | name | ||
| ) |
Retrieves the Substance graph. This function may be used to iterate over the graphs of asset.
| [in] | asset | The Substance asset. |
| [in] | prevGraph | Pass nullptr to get the first graph, pass a graph pointer to get the following graph. |
| [out] | name | Name of the returned graph. Only valid if return value != nullptr. |
| void* GetSubstanceInput | ( | BaseList2D *const | asset, |
| void *const | graph, | ||
| void *const | prevInput, | ||
| UInt32 & | inputUid, | ||
| Int32 & | firstId, | ||
| Int32 & | numElements, | ||
| SUBSTANCE_INPUT_TYPE & | type, | ||
| String & | name | ||
| ) |
Retrieves a Substance input of an asset. This function may be used to iterate over the inputs of a graph of asset.
| [in] | asset | The Substance asset. |
| [in] | graph | The graph. |
| [in] | prevInput | Pass nullptr to get the first input, pass an input pointer to get the following input. |
| [out] | inputUid | The unique ID of the input. Only valid if return value != nullptr. |
| [out] | firstId | The ID of the first component of the input parameter in Cinema 4D (see also numElements). This ID can be used to create a DescID for C4DAtom::SetParameter(). Only valid if return value != nullptr. |
| [out] | numElements | The number of description elements used in Cinema 4D to represent the Substance input parameter. Only valid if return value != nullptr. |
| [out] | type | The data type of the input: SUBSTANCE_INPUT_TYPE. Only valid if return value != nullptr. |
| [out] | name | Name of the returned input. Only valid if return value != nullptr. |
| void* GetSubstanceOutput | ( | BaseList2D *const | asset, |
| void *const | graph, | ||
| void *const | prevOutput, | ||
| UInt32 & | outputUid, | ||
| SUBSTANCE_OUTPUT_TYPE & | type, | ||
| String & | name, | ||
| BaseBitmap ** | bmpPtr | ||
| ) |
Retrieves a Substance input of an asset. This function may be used to iterate over the outputs of a graph of asset.
| [in] | asset | The Substance asset. |
| [in] | graph | The graph. |
| [in] | prevOutput | Pass nullptr to get the first output, pass an output pointer to get the following output. |
| [out] | outputUid | The unique ID of the output. Only valid if return value != nullptr. |
| [out] | type | The output type ID. Only valid if return value != nullptr. |
| [out] | name | The name of the returned output. Only valid if return value != nullptr. |
| [in,out] | bmpPtr | A pointer to a BaseBitmap pointer. If not nullptr, a pointer to a clone of the output channel bitmap will be returned here. The caller owns the pointed BaseBitmap.. Only valid if return value != nullptr. |
| SUBSTANCE_MATERIAL_MODE PrefsGetMaterialModeSetting | ( | ) |
Convenience function to get the material creation mode set in Substance preferences.
| Int32 PrefsGetPreviewSetting | ( | ) |
Convenience function to get the preview mode for Content Browser set in Substance preferences.
| Bool MaterialUsesSubstance | ( | BaseMaterial *const | mat | ) |
Checks if mat contains any Substance shaders.
| [in] | mat | The material to check for Substance shaders. |
| BaseBitmap* GetSubstanceMosaicPreview | ( | BaseList2D *const | asset, |
| Int32 | w, | ||
| Int32 | h | ||
| ) |
Returns an image with previews of the output channels of asset.
| [in] | asset | The Substance asset. |
| [in] | w | The width of the preview image. |
| [in] | h | The weight of the preview image. |
| void UpdateImageInputPaths | ( | BaseList2D *const | asset, |
| String & | path | ||
| ) |
Private.
| void CloneReferencedSubstances | ( | BaseDocument *const | doc, |
| BaseShader *const | shd, | ||
| BaseDocument *const | ddoc, | ||
| BaseShader *const | dshd | ||
| ) |
Private.
| void CloneReferencedSubstancesObject | ( | BaseDocument *const | docSrc, |
| BaseObject *const | opSrc, | ||
| BaseDocument *const | docDst, | ||
| BaseObject *const | opDst | ||
| ) |
Private.
| void InsertSubstancePreviewScene | ( | BaseDocument *const | doc, |
| BaseList2D *const | asset | ||
| ) |
Private.
| const BaseBitmap* GetContentBrowserOverlay | ( | ) |
Returns the Substance logo bitmap. Private.