Help:Lua scripting in RenderWarrior

From RandomControl Wiki

Jump to: navigation, search
Lua.png

RenderWarrior provides a Lua framework that allows you to use some of the most remarkable features in RCSDK (which is the codebase fryrender and Arion are built upon). Basically, this Lua framework provides I/O access to:

Remarkably, you can also invoke Arion and fryrender from Lua, so you can render still frames and animations programmatically.

Some examples of things you could do with scripting are:

Actually, you can do any programmatic modification on scenes, materials or .dsi renders, and batch rendering processes in any way you need.


Highlights


What is Lua?

(From Wikipedia) Lua is a lightweight multi-paradigm programming language designed as a scripting language with extensible semantics as a primary goal.

Lua has gained increased importance in the recent past, after being adopted by many real-time app and video-game developers, perhaps owing to how easy it is to embed, its fast execution, and its small learning curve.

Lua can be considered a high-performance alternative to other older scripting languages such as Python. Actually, you can find a detailed list of the reasons why we chose Lua over Python in this link: Lua vs. Python.

The following code snippet is a very simple Lua script that loads a scene and renders it with Arion:

local s = rcs.new()

rcs.load( s , "c:\\my scenes\\scene.rcs" )

rcs.render_arn( s , "-w:640 -h:480 -passes:25 -rgb:\"z:\\my renders\\output.png\"" )

The following code snippet merges all the .dsi files found in a directory into a single .dsi:

local list = filesys.scan( "z:\\renderwarrior\\renders\\" , "*.dsi" , true , false )

local d = dsi.new()

for i = 0 , #list do

    if ( i == 0 ) then
         dsi.load ( d , list[i] )
    else dsi.merge( d , list[i] ) end

end

dsi.save( d , "z:\\renderwarrior\\merged.dsi" )

If you're serious about mastering Lua scripting, we encourage you to read the Lua documentation or even get one of the official books on Lua. However, note that Lua is really clean and simple, so you may get started by playing around with the example scripts we have included in the Arion and fryrender setups:

How to run Lua from RenderWarrior

Lua scripting is accessed through the commandline, using renderwarrior.exe:

 renderwarrior -{fryrender|arion} -lua:<file>

For example, the following command runs a Lua script picking the installed Arion customer license:

 renderwarrior -arion -lua:"c:\my scripts\turntable.lua"

You can find extended information on RenderWarrior and the supported commandline arguments here.

Reference manual

The Lua framework provided by RenderWarrior is layered in three levels:

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox