Environment VariablesΒΆ

As a rule, Guerilla accepts environment variables in any path. Paths such as "$(TEXTURES)/my_texture.png" is valid as long as TEXTURES is defined as an environment variable. Environment variables are referenced with the $(VARIABLE) syntax.

Environment variables can be recursive, for instance RIBS=$(SCENE_PATH)/ribs

To improve readability, it is advised to all capitals environment variable names.

Predefined environment variables

Guerilla predefines some variables:

  • SCENE_PATH: the directory to the currently loaded project
  • SCENE: the file name of the currently loaded project, without extension
  • RENDER_OUTPUT: set to $(RENDER_WIP) when rendering in the GUI, and to $(RENDER_BATCH) when rendering in batch or on the farm
  • RENDER_WIP: set to "wip"
  • RENDER_BATCH: set to "images"
  • IMAGES: set to $(SCENE_PATH)/$(RENDER_OUTPUT)
  • RENDERTEMP: set to $(SCENE_PATH)/rendertemp
  • JOBS: set to $(SCENE_PATH)/jobs
  • RIBS: set to $(SCENE_PATH)/ribs
  • RENDER_ID: set to the current date and time (as in "20121211_200645" standing for 2012 11 December 20:06:45)
  • PUSHED: the directory where to save the pushed images. If not defined, the images are pushed in $(SCENE_PATH)/pushed

Defining environment variables

There are 2 ways to define environment variables in Guerilla:

Local environment

The local environment is set for the whole Guerilla session. It is named local because it is saved as a local settings. See Preferences > Local Settings > Directories > Local Environment to change this value.

Project environment

The project environment is saved per project. See Preferences > Project Settings > Project Environment.

The project environment overrides the local environment, which means that if a variable is defined in both environments, only the project environment variable is taken.

Some examples of how to use environment variables

In a production environment, you can have an external environment variable set for a show or production, SHOW for instance.

If you consider your textures will always be located in a directory dependent on the show name, you can have:

TEXTURES=/path/to/$(SHOW)/assets/textures

and then always reference your texture files as "$(TEXTURES)/a_texture_file.png"

Using scripting, it is possible to change the project environment variables. For instance, if we know we have an environment variable for a shot, say SHOT, and an environment variable for a sequence, say SEQUENCE, then one could setup the following:

in the project environment, define:

  • RENDER_WIP=$(SCENE_PATH)/wip
  • RENDER_BATCH=/prod/render/$(SEQUENCE)/$(SHOT)/$(RENDER_ID)
  • RENDERPASS=$(RENDER_OUTPUT)/images/$l_$n_$o.$05f.$x
  • JOBS=$(RENDER_OUTPUT)/data/jobs
  • RIBS=$(RENDER_OUTPUT)/data/jobs
  • RENDERTEMP=$(RENDER_OUTPUT)/data/temp
  • IMAGES=$(RENDER_OUTPUT)/images

in your RenderPasses, set the file pattern as "$(RENDERPASS)"

When rendering with the GUI, the RenderPass will output images into $(SCENE_PATH)/wip/images, and other processes will output in the default location.

When rendering in batch or on the farm, the RenderPass will output images into /prod/render/$(SEQUENCE)/$(SHOT)/$(RENDER_ID)/images, and other processes will output in the images or in the temp directory.

The RENDER_ID is useful to prevent from 2 consecutive renders of the same project to overwrite the jobs, ribs and genereated images files.

Printing an environment variable in the Guerilla Console

You can print the content of a environment variable using the os.getenv Lua function:

print (os.getenv ("MYVARIABLE"))

You can get the actual (or expanded) value of a variable or path using the fs.expand Lua function:

print (fs.expand ("$(IMAGES)/my_image.png"))