Terragen 4 Global Illumination
Global Illumination in Computer Graphics
Global illumination is a general name for a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting to 3D scenes. Such algorithms take into account not only the light which comes directly from a light source (direct illumination), but also subsequent cases in which light rays from the same source are reflected by other surfaces in the scene, whether reflective or not (indirect illumination). http://en.wikipedia.org/wiki/Global_illumination
Global Illumination in Terragen
Direct illumination in Terragen is the lighting coming directly from the sun or other specific light sources, but not from luminous objects. Global illumination (GI) in Terragen means the lighting from everywhere else, including indirect illumination as well as illumination caused by bright, luminous objects that aren't specifically light sources. In a Terragen scene, the intensity of GI is controlled using a single Enviro Light nodeA single object or device in the node network which generates or modifies data and may accept input data or create output data or both, depending on its function. Nodes usually have their own settings which control the data they create or how they modify data passing through them. Nodes are connected together in a network to perform work in a network-based user interface. In Terragen 2 nodes are connected together to describe a scene..
In Terragen, GI is:
- The reason shadows are not black.
- Lighting from the sky.
- Lighting caused by light bouncing off other objects.
- Lighting caused by light emitted from glowing, luminous objects, e.g. lava, fire, bioluminescence.
- "Multiple scattering" in clouds and atmospheres. "Multiple scattering" in volumes is often thought of as a separate phenomenon from global illumination, but in fact it can be treated as a form of global illumination if the scattering is rendered as a lighting effect upon the volume. In Terragen, multiple scattering is approximated using the global illumination cache. Clouds and atmospheres will illuminate themselves in a way that simulates multiple scattering. Being part of the global illumination system, GI in volumes completely integrates with GI from surfaces. Light bouncing off or emitted from surfaces will light up clouds and atmospheres, and light scattering through clouds and atmospheres will light up surfaces.
Rendering with GI
Rendering without GI cache files
To render an image with Global Illumination in Terragen without using GI cache files, you need the following:
- An Enviro Light in the scene, enabled, with its mode set to "Global Illumination"
- In Render GI Settings, 'GI relative detail' set to 1 or higher.
You can turn off global illumination by disabling the Enviro Light, but Terragen might still waste time on the pre-pass. To completely turn off GI, edit the Render GI settings and set 'GI relative detail' to 0. All other GI settings can be left how they are.
Performance note: Do not enable more than one Enviro Light in the scene unless you really need to. If you wish to brighten the effect of the Enviro Light, increase the 'strength' settings in a single Enviro Light. Multiple Enviro Lights can increase GI quality, but they are not the best way to do that and they increase render time unnecessarily. You can achieve a more efficient increase in quality by increasing 'GI sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. quality' in Render GI Settings. This will give a higher quality in a shorter render time than would enabling multiple Enviro Lights. The only good use for more than one enabled Enviro Light is to have one Enviro Light in Global Illumination mode and another in Ambient Occlusion mode, if you want that effect. Of course you can have as many disabled Enviro Lights in your project as you like.
Normally when you render an image with Global Illumination, Terragen renders the image in two passes. A pre-pass is rendered which calculates the Global Illumination for the image and stores it in a spatial data structure called a GI cache. When you see lots of tiny dots filling the image before the real rendering begins, you're seeing the pre-pass generating the GI cache. Once the pre-pass is done, rendering of the final pass begins. Global Illumination in the final image depends on the GI cache that was generated in the pre-pass.
Rendering with GI cache files
A new feature in Terragen 2.4 (not in the Free Non-Commercial Edition) is the ability to read and write GI cache files. These allow you to write the results of the pre-pass to disk or file network and to read them back in when rendering an image. Using GI caches files is a two step process. First you render a pre-pass which calculates the Global Illumination for the image (or sequence of images), and writes the resulting GI cache to your disk or network in the form of a GI cache file (or sequence of GI cache files). After you have created those GI cache files, you can render final images using the GI in the cache files instead of recalculating the GI every time you render an image.
You don't need to use GI cache files to enjoy Global Illumination. However, GI caches have many uses, such as:
- Eliminating GI flicker in animations. To do this, read a single cache file or interpolate between cache files in a sequence.
- Matching the GI in separately rendered tiles that you want to combine into a larger image, panorama, skybox or skydome. This is achieved by reading a single cache file or blending multiple cache files rendered with different cameras.
- Rendering a GI pass (indirect illumination pass), by disabling all lights and reading the GI from a GI cache file.
- Rendering special effects using GI that was generated with different lighting or other changes to the scene, e.g. some objects added or removed. You could write to a GI cache file using the scene that generates the GI you want, then render your final image with that GI cache file.
- More control over the level of detail in your GI pre-pass than is possible with the GI relative detail setting, which only allows whole number values. When writing to the GI cache, you can choose a different image size to render or a different value for 'detail'. Normally, 'detail' affects many things in your rendered image, but if you render the GI cache separately then you can choose a different detail for your GI. Image size and detail both have the same effect on the detail of your GI solution as 'GI relative detail' -- they are all linear multipliers -- but you can change the detail more precisely with image size or the detail slider than you can with GI relative detail.
Generating a GI cache file sequence for animation
- Setup the lighting how you want it, doing test renders with "No GI cache file" checked in Render GI Settings (this is the default).
- Switch to "Write to GI cache file" in Render GI Settings. Specify a location and filename for your GI cache file. Include a frame formatter such as '%04d' (not including quotes) somewhere in the filename. This formatter will be replaced by the frame number, so that you can render a sequence of cache files. One file will be generated for each frame that you render.
- Generate the GI cache files by rendering a sequence, just like you would render a sequence of images. Final images will not be rendered or saved while "Write to GI cache file" is checked. You do not have to render every frame. "Time-sparse" caches, where cache files are separate by more than one frame, are useful to allow the final images to gradually blend between GI solutions instead of flickering from frame to frame. You can either render the sequence on your computer using the "Render Sequence" button or distribute it on a render farm like you would for final images. Generating caches for an animation can be distributed across many machines because each frame generates a different GI cache file.
Using the "time-sparse" technique is simply a matter of generating fewer files using a sequence where the frame step is greater than 1. For example, you might choose to render frames 10, 20, 30, etc. by setting the step to 10. However, if you change the step, it's especially important to be aware that any old files that exist from previous renders will be deleted only if they are overwritten by your latest render. They are not automatically deleted when you start rendering a new sequence. When reading the caches for your final image pass, Terragen simply looks at whatever files exist that match the file sequence you tell it to read.
Rendering a final animation
- Switch to "Read GI cache file(s)" in Render GI Settings. Specify the filename of one of the GI cache files that you generated. Any file in the sequence will do.
- Set blend mode to "Interpolate (for animation)". In most cases this is the best mode for animations. It is designed to work with time-sparse caches and gradually blend between sets of files according to the frame number. It will also work when there is a cache file for every frame, but in that situation it is equivalent to "Equal blend within range" mode except that it will blend one fewer cache files due to the nature of the interpolation algorithm. The various blend modes are explained in more detail in the Render GI Settings section.
- Choose the number of cache files to blend together to produce the GI solution for each frame. The higher this number, the higher the quality of the GI and the smaller the fluctuations will be while playing the sequence. If you have a GI cache file on every frame then it is even more important because it affects how much the GI flicker is reduced. However, higher numbers increase render time of the final images. If the GI cache files are quite large, especially if they were generated with a high GI sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. quality setting, then this effect on render time may be significant.
- If there is too much fluctuation in the GI you have three options. A) You can slow down the fluctuations by moving some of the GI files out of the folder to make the caches even more sparse. However, this uses files that are farther away in time from the current frame, and if your camera is moving too rapidly you may see areas of inadequate GI coverage or reduced quality. B) Increase the "number of files to blend". Usually this will decrease fluctuations or flicker, but it may affect render times. If the camera is moving rapidly so that the extra files do not cover the region 3D space being rendered then the extra files may not even help. If all else fails you may need to re-generate GI cache files with a higher GI sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. quality, but this might also increase render times for the final images.
If in doubt, a good starting point is to generate GI cache files with quality settings that work for still images you're happy with, generate every 10th GI cache file and set it to blend 3, 4 or 5 files for the final sequence.
Render GI Settings
- GI relative detail: TBC
- GI sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. quality: TBC
- GI blur radius: Each GI sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. point affects a spherical region of space in the final image, and where multiple sampleA sample refers to a value or set of values at a point in time and/or space. The defining point of a sample is that it is a chosen value out of a continuous signal. In Terragen 2 it is usually a mathematical (procedural) function that is being sampled. spheres overlap they are averaged together. The radius of these spheres depends on various things that are decided by the renderer, but you can control a minimum radius that is enforced to ensure that enough samples overlap on every part of the image. GI blur radius affects this minimum radius in image space. Although it is in image space it is not measure in pixels. It is relative to the spacing of the GI prepass samples that you see in the prepass, but not including the extra samples created by "Supersample prepass". Because it is relative to the spacing of these samples, if you increase "Detail" (Render settings) or "GI relative detail", the blur area in image space will be reduced. It works this way so that changing "Detail" or "GI relative detail" changes overall detail without needing think about the blur radius. The default value is 8. Lower values may give the impression of greater detail in GI but can lead to increased blotchiness in images and flickering in animations. Increased GI blur radius can lead to smoother GI but apparent detail will likely be reduced. We believe that 8 is a good compromise for most renders.
- Supersample prepass: TBC
GI Cache File:
- No GI cache file: Renders the image normally. A prepass generates the GI and an image pass renders the final image.
- Write to GI cache file: Renders only the prepass to generate the GI cache, then saves the GI cache to a file.
- Read GI cache file(s): Renders only the final image. GI is read from a previously generated GI cache file or GI cache files.
- Blend mode: Applies only when "Read GI cache file(s)" is selected. Blend mode can be set to one of the options below. "One file (exact filename)" reads a single cache file, but the other 3 modes work with sequences of files. If the base filename contains a number and other files in the same folder have similar names which differ only by this number, then they will be assumed to be part of the same sequence and the number will be interpreted as a frame number. The current frame number and the blend mode determine which file(s) in the sequence will be read.
- One file (exact filename): Reads only one cache file, with the filename given to the right of "Read GI cache file(s)". This can be an exact filename, or if the filename contains '%04d' (without quotes) then that string will be replaced by a 4 digit frame number representing the current frame. Different numbers of digits are supported by replacing the '4' with a different number. If the file is not found then the renderer will report an error; sequences are not detected in this mode.
- Nearest file in sequence: Beginning with the base filename (given to the right of "Read GI cache files"), this mode looks for files that belong to same sequence as the base filename. The renderer will read only one cache file, choosing the file whose frame number is nearest to the current frame number. You can choose any file in the sequence for the base filename.
- Equal blend within range: Beginning with the base filename (given to the right of "Read GI cache files"), this mode looks for files that belong to same sequence as the base filename. The renderer will try to read as many files as the "Number of files to blend" parameterA parameter is an individual setting in a node parameter view which controls some aspect of the node. below, choosing the files whose frame numbers are nearest to the current frame number. Where the GI solutions overlap in 3D space, the results are averaged together, and wherever there are gaps in one file's solution (e.g. outside the camera's view) the other files can fill in data. You can choose any file in the sequence for the base filename.
- Interpolate (for animation): This is simillar to "Equal blend within range" except that the files are weighted differently depending on the current frame number, to produce steady blends during animations. This mode becomes useful if your caches are 'sparse' in time. 'Sparse caches' are sequences of GI cache files where not every frame has a cache file. For example you might have a GI cache file on frames 10, 20, 30, and so on. If you do this, and you set the blend mode to "Interpolate (for animation)", a smooth blend will occur between the different sets of GI caches that are selected over the course of an animation. The more frames between cache files, the more gradual the blend will be. A ramp up/down weighting is applied to the first and last files that are used, giving you a linear interpolation between the results of different sets of files so that you don't see any pops between frames where the sets change. (Pops may still occur in places in 3D space where there is insufficient coverage by the cache files.) "Number of files to blend" should be set to 2 or more to allow the blending to work. This mode will also work when there is a cache file for every frame, but in that situation it is equivalent to "Equal blend within range" mode except that it will blend one fewer cache files due to the nature of the interpolation algorithm.
- Number of files to blend: When the blend mode is "Equal blend within range" or "Interpolate (for animation)", this is the maximum number of GI cache files that will be read and blended together to render a frame. If the blend mode is "Interpolate (for animation)" then on some frames it will read one fewer files. This is because the linear interpolation sometimes causes the first or last file within range to have a weight of zero.
- GI prepass padding: This specifes how much to enlarge the area of image calculated during the prepass, which may be useful to avoid mismatched lighting between adjacent cropped renders or pieces of a panorama when not using GI cache files (GI cache files effectively solve this problem). A value of 0 means no padding. A value of 1 adds a border to each side of the frustum which is equivalent to the width or height of the image or crop region, which makes the frustum 3 times as wide and 3 times as tall. Negative values shrink the area/frustum instead of enlarging it.
- GI surface details: TBC