Tuesday, 18 November 2014

Changing the Octane background image each frame in Modo

The OctaneRender for Modo plugin does not support animated backgrounds (since the background is not saved by Octane in the png when the Viewport is saved).  However there may be situations where you still want to see the background image change when you change frames on the Modo timeline.  The following LUA script will do this.

1) Copy and paste the following code into AnimateBackground.lua (save it somewhere on your filesystem)

 -- lua  
 fps = lxeval( "time.fpsCustom ?" )  
 frametime = lxeval( "select.time ?" )  
 ok = lx( "octane.selectKernel" )  
 local str = string.format("c:\\MyDocuments\\MyBackgroundImage_%04i.jpg", frametime[1] * fps[1]);  
 ok = lx( "item.channel oc_backgroundImageFilename {".. str .."}" )  

2) Each time you move the Modo frame slider, run the above script (via Modo -> System -> Run Script -> AnimateBackground.lua).  For frame 0 it will load MyBackgroundImage_0000.jpg.  For frame 1, MyBackgroundImage_0001.jpg, etc.  You may need to adjust the code to select the correct file.

You can also run the script from the Modo command panel via the following command:
@{c:\PathToTheLuaScript\AnimateBackground.lua}
You could also use python code instead of LUA to achieve the same result.

No comments:

Post a Comment