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.
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:
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.
The project environment is saved per project. See Preferences > Project Settings > Project Environment.
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:
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:
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.
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"))