Substance Elements Manual
The Substance integration introduces a few new elements. These elements are:
These elements are typically handled with the functions described in Substance Functions Manual .
A Substance asset is not represented by a dedicated class. Instead a basic
BaseList2D
element is used. The parameter IDs are stored in
nsubstanceasset.h
.
// check if the given C4DAtom is a Substance asset if (substance->GetType() != ID_SUBSTANCE_ASSET ) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION );
// print filename if (!substance->GetParameter( DescLevel ( SUBSTANCEASSET_FILENAME ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// read SUBSTANCEASSET_ENABLED parameter if (!substance->GetParameter( DescLevel ( SUBSTANCEASSET_ENABLED ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// check if enabled if (data. GetBool ()) ApplicationOutput ( "Substance is enabled" );
// get status if (!substance->GetParameter( DescLevel ( SUBSTANCEASSET_STATUS ), data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Status: " + data. GetString ());
The Substance shader references a Substance asset and a selected output channel in
Cinema 4D
's material system (or all other places, where shaders can be used). The parameters are defined in
xsubstance.h
.
另请参阅 Materials and Shaders Overview .
// This example creates a new Substance shader linked to the given Substance asset. // The asset is scanned for a bump output channel that is used in that shader.// create a new Substance shader BaseShader * const shader = CreateSubstanceShader (substance); if (shader == nullptr ) return maxon::UnknownError( MAXON_SOURCE_LOCATION );
// insert shader into material and use in bump channel material-> InsertShader (shader); material-> SetParameter ( DescLevel ( MATERIAL_BUMP_SHADER ), shader, DESCFLAGS_SET::NONE ); material-> SetParameter ( DescLevel ( MATERIAL_USE_BUMP ), true , DESCFLAGS_SET::NONE );
// check all output channels void * output = nullptr ; do { UInt32 outputID; SUBSTANCE_OUTPUT_TYPE type; String outputName; output = GetSubstanceOutput (substance, graph, output, outputID, type, outputName, nullptr );
// check if the output could be obtained and if that output is a "Bump" output const Bool validOutput = output != nullptr ; const Bool typeIsBump = type == SUBSTANCE_OUTPUT_TYPE::BUMP ; if (validOutput && typeIsBump) { shader-> SetParameter ( DescLevel ( SUBSTANCESHADER_CHANNEL ), Int32 (outputID), DESCFLAGS_SET::NONE ); } } while (output != nullptr );
Substance presets can be stored in the Content Browser.
The Substance preferences define the type and behaviour of the integrated Substance Engine and influence the workflow of working with Substance assets. The parameters are defined in
prefssubstance.h
.