Everything related to the integration for Cinema 4D.

I have an exr sky sequence that I want to use as a background in my render. I can load the first .exr/frame in the background channel, but how do I make the background channel advance one .exr/frame for each .mxs frame that is exported?

I can do this with a normal C4D material assigned to a C4D sky, but the Maxwell plugins doesn't let me do it the same way.

Maybe there is another way?

Thanks again.

Your script works great (thanks!) for my workflow with formZ (which can't do this either). It works with the C4D project I am doing as well, but it takes 1,25 mins. to get through each frame - I think because of the size of the .mxs files/frames.

I have to go through approx 1500 frames several times over the next 4 weeks. With a processing time of 30 hours that has become a bit of an issue - and that's why I was looking for an altenative solution for the C4D scenes.

I was able to figure out something that works pretty well, using the Python tag (attached to a Scene Object).
Code: Select all

import c4d
import os
import re

# This script is intended to be put into a Python tag assigned to a Scene
# Object. When it is evaluated, it checks the current frame number, looks at
# the paths of all the Scene's IBL paths, and rewrites any that if finds to
# have sequential names.
# You can change FRAMES_PER_HDRI below to control how many frames are assigned
# to a given sequential HDRI. For example, if you change it to 10, then the
# first 10 frames will use file_0000, the second 10 will use file_0001, and
# so forth.
# Lastly, note that because it appears the Python tag is evaluated after the
# plugin has already written the MXS, this script actually has to use frame+1
# for the value. This means that you should skip exporting the first frame of
# your animation, since it will have the wrong HDRI assigned; for example, if
# you intended to export frames 0-9, you should instead export frames 1-10.

def split_name(file):
    if not file:
        return None, None, None, -1
    name,ext = os.path.splitext(file)
    m = re.search(r'[0-9]+$', name)
    if not m:
        return None, None, None, -1
    i = m.start()
    basename = name[:i]
    if not basename:
        return None, None, None, -1
        seqstr = name[i:]
        seqnum = int(seqstr)
    except ValueError:
        return None, None, None, -1
    return basename,seqstr,ext,seqnum

def main():
    scene = op.GetObject()
    if not scene:
        print('Failed to get parent Scene.')
    ID_MXSCENEOBJECT = 1009988
    if scene.GetType() != ID_MXSCENEOBJECT:
        print('Parent object is not a Scene.')
    frame = int(doc.GetTime().GetFrame(doc.GetFps())/FRAMES_PER_HDRI)+1
    if frame < 0:
        print('Cannot auto-sequence for negative frames.')

    paths = {
    for key,path in paths.iteritems():
        dir = os.path.dirname(path)
        file = os.path.basename(path)
        basename,seqstr,ext,seqnum = split_name(file)
        if (not basename) or (not seqstr) or (not ext) or (seqnum == -1):
        newseqstr = format(frame, "0%dd" % len(seqstr))
        scene[key] = os.path.join(dir, basename + newseqstr + ext)

As mentioned in the comments, you can use the FRAMES_PER_HDRI variable to use a given (sequentially-named, meaning a filename with some number of digits directly preceding the extension) HDRI for more than one frame (I recall you asked about this in your other question).

Also mentioned is that because the plugin has already written the HDRI path by the time the Python tag is evaluted, this script is purposefully assigning the wrong HDRI to the Scene Object when it is evaluated -- while exporting frame 0, the script sets the Scene Object to use HDRI 1, which is then written while exporting frame 1, and so forth.

The logic of the path replacement is just this: if any IBL path is found to have a sequential name, the sequential part of the name is replaced with a different sequential part, based on the frame number currently being exported. So, it rewrites those types of HDRI paths, but does nothing with paths that are unassigned, or assigned a non-sequential path.
MXM data base.

At the very least I hope that upon relaunch there […]

Maxwell Render V5 Series

from my (somewhat narrow) point of view I can tel[…]

Thanks Fernando If this will work in the next rele[…]

ilgioma - Gallery

Thanks choo-chee I am very pleased that you like i[…]