This tutorial shows how to use Python to update only the camera in a static scene and re-render without re-cooking geometry.
In some scenes, there are large geometry datasets or procedurals that take significant time to load but that do not change from frame to frame. In these cases, it is nice to take advantage of this and not be forced to reload or rebuild the geometry. Arnold allows us to update or add nodes, and the raytracing acceleration data structures are not view-dependent, which is why IPR re-renders are so fast. We can take advantage of this.
If you have a static scene with an animating camera, you will need to update two nodes every frame: the camera and the output driver. Obviously, if you want to render from a new location, you need to have the new camera. The output driver's filename needs to be updated because, if you used the same exact driver, you would overwrite the frame you had previously rendered.
In the script below, the Python function AiASSLoad(assfile, AI_NODE_ALL) reads in everything from an ass file. We call this for the first frame we render, but we don't want subsequent frames to re-read in our static geometry. We do this by reading in only the camera, driver, filter, and option nodes using AiASSLoad(assdir+ass, AI_NODE_CAMERA | AI_NODE_DRIVER | AI_NODE_FILTER | AI_NODE_OPTIONS).
Arnold is happy to have as many cameras drivers and filters as a user chooses to put into a scene, but we want to replace these nodes with the new ones. To do this, we just loop through and delete all cameras, drivers, and filters. That leaves our scene ready for the new ones we will read into the scene. Then, after we read them in, we need to make a list of them, so we can easily delete them later for the next frame.
Finally, we simply render the frame and loop back. This method was used to render the Mandelbulb sequence for the Managing RAM and threading in procedurals tutorial. A high-resolution Mandelbulb takes about 45 minutes to compute, but only 4 minutes to render. This was a perfect test for this Python script, and there is a ten frame sequence of .ass files attached for you to test this script with.
This type of script was used to render this sequence: Mandelbulb. The quarter billion spheres took significant time to generate, but the re-renders were quite fast.
This second example needs the multilight_area.ass file attached. It will first render the scene, then update the vertices of the area light called "light_0003", and then re-render.