About
A Material object represents a Cinema 4D standard material. It is based on BaseMaterial. A standard material offers multiple parameters organized in "channels".
Material objects are an instance of Mmaterial.
Access
A Material is accessed like any other material.
See also BaseMaterial Manual.
Allocation/Deallocation
Material objects are created with the usual tools.
- Material::Alloc(): Creates a new Material.
 
- Material::Free(): Deletes the given Material.
 
  
 
  Material* const material = Material::Alloc();
  if (material == nullptr)
 
  const Vector blue { 0.0, 0.0, 1.0 };
 
  material->SetName("Blue Material"_s);
 
  doc->InsertMaterial(material);
 
NONE
Definition: asset_browser.h:1
 
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
 
#define ConstDescID(...)
Definition: lib_description.h:592
 
@ MATERIAL_COLOR_COLOR
Definition: mmaterial.h:56
 
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
 
const char * doc
Definition: pyerrors.h:226
 
  
Properties
The parameters of a Material can be edited as usual with C4DAtom::SetParameter() and C4DAtom::GetParameter(). The parameter IDs are defined in mmaterial.h. For convenience the parameters of a group are often combined to a "channel".
Channel States
These utility functions allow to edit the state of a "channel":
- Material::GetChannelState(): Returns the state of the given channel.
 
- Material::SetChannelState(): Sets the state of the given channel.
 
  
 
 
#define CHANNEL_COLOR
The color channel of a material.
Definition: c4d_shader.h:94
 
maxon::Bool Bool
Definition: ge_sys_math.h:46
 
  
Channels
Certain parameters and functionality of a parameter group are combined in a BaseChannel object:
- BaseMaterial::GetChannel(): Returns a BaseChannel object.
 
The returned BaseChannel object can be used to handle the referenced shaders:
- BaseChannel::InitTexture(): Initializes the channel texture, loading any files required.
 
- BaseChannel::FreeTexture(): Frees all resources used by this channel.
 
Between the call of InitTexture() and FreeTexture() the shader of the channel can be sampled:
- BaseChannel::GetBitmap(): Retrieves the channels bitmap texture.
 
- BaseChannel::Sample(): Samples the channel's shader.
 
Further operations are:
- BaseChannel::GetShaderID(): Returns the ID of the channel's shader.
 
- BaseChannel::GetShader(): Returns the channel's shader.
 
- BaseChannel::Compare(): Returns true if the given BaseChannel is identical.
 
These functions are useful to get general settings of the channel and the settings of a used bitmap shader:
- BaseChannel::GetData(): Returns a BaseContainer with the settings.
 
- BaseChannel::SetData(): Sets the settings with the values stored in the given BaseContainer.
 
  
 
  
  BaseChannel* 
const channel = material->GetChannel(
CHANNEL_COLOR);
 
  if (channel == nullptr)
 
  
  BaseShader* const shader = channel->GetShader();
  if (shader != nullptr)
 
  
  if (shader != 
nullptr && shader->IsInstanceOf(
Xbitmap))
 
  {
    const BaseContainer bc = channel->GetData();
  }
#define BASECHANNEL_TEXTURE
String. The texture for this channel.
Definition: c4d_shader.h:119
 
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
 
#define Xbitmap
Bitmap.
Definition: ge_prepass.h:1331
 
  
Reflection Layers
A standard material can manage multiple reflection layers. Such reflection layers can be created and edited. The used parameter IDs are defined in c4d_reflection.h, see REFLECTION_LAYER.
- Material::AddReflectionLayer(): Creates and returns a new reflection layer.
 
- Material::GetReflectionLayerID(): Returns the reflection layer with the given ID.
 
- Material::GetReflectionLayerIndex(): Returns the reflection layer at the given index.
 
- Material::GetReflectionLayerTrans(): Returns the transparency layer.
 
- Material::GetReflectionLayerCount(): Returns the number of reflection layers.
 
- Material::RemoveReflectionLayerID(): Removes the reflection layer with the given ID.
 
- Material::RemoveReflectionLayerIndex(): Removes the reflection layer at the given index.
 
- Material::RemoveReflectionAllLayers(): Removes all reflection layers.
 
- Material::GetAllReflectionShaders(): Gets an array of all shaders used by reflection layers.
 
- Material::GetReflectionPrimaryLayers(): Gets the indices to the primary reflection and specular layers (can be -1 for empty).
 
The settings of a ReflectionLayer object are:
- ReflectionLayer::GetDataID(): Returns the ID of the reflection layer.
 
- ReflectionLayer::GetName(): Returns the name of the layer.
 
- ReflectionLayer::SetName(): Sets the name of the layer.
 
- ReflectionLayer::GetLayerID(): Returns the ID of the layer.
 
- ReflectionLayer::GetFlags(): Returns the flags of the layer. See REFLECTION_FLAG.
 
- ReflectionLayer::SetFlags() Sets the flags of the layer.
 
- Note
 - If a Material is created and configured in some import context (e.g. SceneLoaderData) one has to set the material parameter REFLECTION_LAYER_IMPORTED to true.
 
  
 
  
  ReflectionLayer* const layer = material->AddReflectionLayer();
  if (layer == nullptr)
 
  const Int32 layerID = layer->GetDataID();
 
 
  
  layer->SetName("Gold Layer"_s);
 
 
 
#define REFLECTION_DISTRIBUTION_BECKMANN
Beckmann.
Definition: c4d_reflection.h:49
 
#define REFLECTION_FLAG_ACTIVE
Active.
Definition: c4d_reflection.h:23
 
#define REFLECTION_FLAG_TAB
Tab.
Definition: c4d_reflection.h:24
 
#define REFLECTION_FLAG_SELECTED
Selected.
Definition: c4d_reflection.h:22
 
#define REFLECTION_FRESNEL_METAL_GOLD
Gold.
Definition: c4d_reflection.h:190
 
#define REFLECTION_FRESNEL_CONDUCTOR
Conductor.
Definition: c4d_reflection.h:153
 
#define REFLECTION_LAYER_FRESNEL_METAL
::Int32 Metal preset: REFLECTION_FRESNEL_METAL
Definition: c4d_reflection.h:382
 
#define REFLECTION_LAYER_FRESNEL_MODE
::Int32 Fresnel mode: REFLECTION_FRESNEL
Definition: c4d_reflection.h:380
 
#define REFLECTION_LAYER_MAIN_DISTRIBUTION
::Int32 Distribution type: REFLECTION_DISTRIBUTION
Definition: c4d_reflection.h:287
 
#define CreateDescID(...)
Definition: lib_description.h:593
 
maxon::Int32 Int32
Definition: ge_sys_math.h:51
 
 and
  
 
  const Int32 layerCount = material->GetReflectionLayerCount();
 
 
  {
    ReflectionLayer* 
const layer = material->GetReflectionLayerIndex(
i);
 
    if (layer == nullptr)
 
    
 
    const Int32 layerID = layer->GetDataID();
 
 
    GeData data;
 
    
 
 
    
 
    
 
    
  }
Py_ssize_t i
Definition: abstract.h:645
 
PyObject * value
Definition: abstract.h:715
 
#define REFLECTION_LAYER_MAIN_BLEND_MODE
::Int32 Blend mode.
Definition: c4d_reflection.h:291
 
#define REFLECTION_LAYER_TRANS_BRIGHTNESS
::Float Brightness.
Definition: c4d_reflection.h:337
 
@ MATERIAL_TEXTUREMIXING_ADD
Definition: mmaterial.h:61
 
@ MATERIAL_TEXTUREMIXING_NORMAL
Definition: mmaterial.h:60
 
maxon::Float Float
Definition: ge_sys_math.h:57
 
 See also Blog post: Cinema 4D R16 Reflectance channel's API
Further Reading