Open Search
    MultipassObject Manual

    About

    A MultipassObject represents a multipass element of the render settings. Cinema 4D's render engines will render and save different multipasses based on these settings.

    MultipassObject objects are an instance of Zmultipass.

    // This example searches for the "depth" multipass.
    // If it is not found, it will be created.
    RenderData* const renderData = doc->GetActiveRenderData();
    MultipassObject* multipass = renderData->GetFirstMultipass();
    MultipassObject* depthPass = nullptr;
    while (multipass != nullptr)
    {
    BaseContainer& data = multipass->GetDataInstanceRef();
    const Int32 type = data.GetInt32(MULTIPASSOBJECT_TYPE);
    {
    depthPass = multipass;
    break;
    }
    multipass = multipass->GetNext();
    }
    if (depthPass == nullptr)
    {
    // allocate multipass
    depthPass = static_cast<MultipassObject*>(BaseList2D::Alloc(Zmultipass));
    if (depthPass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    // set to depth pass
    BaseContainer& data = depthPass->GetDataInstanceRef();
    // insert
    renderData->InsertMultipass(depthPass);
    renderData->Message(MSG_UPDATE);
    }
    // enable multi-passes
    renderData->SetParameter(ConstDescID(DescLevel(RDATA_MULTIPASS_ENABLE)), true, DESCFLAGS_SET::NONE);
    NONE
    Definition: asset_browser.h:1
    @ RDATA_MULTIPASS_ENABLE
    Definition: drendersettings.h:332
    #define MSG_UPDATE
    Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
    Definition: c4d_baselist.h:372
    #define MAXON_SOURCE_LOCATION
    Definition: memoryallocationbase.h:69
    #define VPBUFFER_DEPTH
    Depth multipass channel.
    Definition: c4d_videopostdata.h:130
    #define Zmultipass
    Definition: ge_prepass.h:1303
    #define ConstDescID(...)
    Definition: lib_description.h:596
    maxon::Int32 Int32
    Definition: ge_sys_math.h:51
    PyObject ** type
    Definition: pycore_pyerrors.h:34
    const char * doc
    Definition: pyerrors.h:226
    @ MULTIPASSOBJECT_TYPE
    Definition: zmultipass.h:6

    Access

    Existing MultipassObject elements are stored in a list and can be accessed from a RenderData object:

    • RenderData::GetFirstMultipass(): Returns the first MultipassObject element.

    Allocation/Deallocation

    The MultipassObject class does not offer a static "Alloc" or "Free" function so the functions of BaseList2D have to be used with Zmultipass.

    • BaseList2D::Alloc(): Can be used to create a new MultipassObject object.
    • BaseList2D::Free(): Can be used to delete the given MultipassObject object.

    A newly created MultipassObject is added to the render settings by adding it to the RenderData object:

    • RenderData::InsertMultipass(): inserts a MultipassObject element into the list.
    // allocate multipass
    MultipassObject* const depthPass = (MultipassObject*)BaseList2D::Alloc(Zmultipass);
    if (depthPass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    // set to depth pass
    BaseContainer& data = depthPass->GetDataInstanceRef();
    // insert
    renderData->InsertMultipass(depthPass);

    Navigate

    MultipassObject objects are organized in a list:

    • MultipassObject::GetNext(): Returns the next MultipassObject in the list.
    • MultipassObject::GetPred(): Returns the previous MultipassObject in the list.
    // This example loops through all multipasses and prints their names.
    RenderData* const renderData = doc->GetActiveRenderData();
    MultipassObject* multipass = renderData->GetFirstMultipass();
    while (multipass != nullptr)
    {
    ApplicationOutput("Multipass: " + multipass->GetName());
    multipass = multipass->GetNext();
    }
    #define ApplicationOutput(formatString,...)
    Definition: debugdiagnostics.h:204

    Types

    All multipasses are MultipassObject objects. They only differ in their parameters. The type of a multipass is defined with:

    Simple multipass types are:

    Configurable multipass types are:

    The parameter IDs of configurable multipasses are defined in zmultipass.h.

    Additional multipass types are:

    • VPBUFFER_ALLPOSTEFFECTS: All post effects channel. Use this to create the "Post Effects" multipass needed to support custom multipasses created by VideoPostData plugins.
    • VPBUFFER_IMAGEBUILDING_PASS: The maximum number of the image building layers. This can be used to loop through the multipass types.

    Example object buffer:

    // This example creates an object buffer multipass.
    MultipassObject* const multipass = static_cast<MultipassObject*>(BaseList2D::Alloc(Zmultipass));
    if (multipass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    BaseContainer& data = multipass->GetDataInstanceRef();
    data.SetInt32(MULTIPASSOBJECT_OBJECTBUFFER, 99);
    renderData->InsertMultipass(multipass);
    #define VPBUFFER_OBJECTBUFFER
    Object buffer multipass channel.
    Definition: c4d_videopostdata.h:140
    @ MULTIPASSOBJECT_OBJECTBUFFER
    Definition: zmultipass.h:8

    Example blend channel:

    // This example creates an blend multipass.
    MultipassObject* const multipass = static_cast<MultipassObject*>(BaseList2D::Alloc(Zmultipass));
    if (multipass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    BaseContainer& data = multipass->GetDataInstanceRef();
    data.SetBool(MULTIPASSOBJECT_DIFFUSE, true);
    data.SetBool(MULTIPASSOBJECT_SHADOW, true);
    renderData->InsertMultipass(multipass);
    #define VPBUFFER_BLEND
    Blend multipass channel.
    Definition: c4d_videopostdata.h:150
    @ MULTIPASSOBJECT_DIFFUSE
    Definition: zmultipass.h:14
    @ MULTIPASSOBJECT_SHADOW
    Definition: zmultipass.h:16

    Example reflection channel:

    // This example creates a reflection multipass.
    MultipassObject* const multipass = static_cast<MultipassObject*>(BaseList2D::Alloc(Zmultipass));
    if (multipass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    BaseContainer& data = multipass->GetDataInstanceRef();
    renderData->InsertMultipass(multipass);
    #define VPBUFFER_REFLECTION
    Reflection multipass channel.
    Definition: c4d_videopostdata.h:120
    @ MULTIPASSOBJECT_REFLECTION_MATERIALS
    Definition: zmultipass.h:25
    @ MULTIPASSOBJECT_REFLECTION_SEPARATE_ALL
    Definition: zmultipass.h:27

    Example specular channel:

    // This example creates a specular multipass.
    MultipassObject* const multipass = static_cast<MultipassObject*>(BaseList2D::Alloc(Zmultipass));
    if (multipass == nullptr)
    return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
    BaseContainer& data = multipass->GetDataInstanceRef();
    renderData->InsertMultipass(multipass);
    #define VPBUFFER_SPECULAR
    Specular multipass channel.
    Definition: c4d_videopostdata.h:118
    @ MULTIPASSOBJECT_SPECULAR_SEPARATE_ALL
    Definition: zmultipass.h:40
    @ MULTIPASSOBJECT_SPECULAR_MATERIALS
    Definition: zmultipass.h:38

    Further Reading