Ray Trace Objects and Defer Atmosphere/Cloud
This document was originally written for Terragen 2.1. Some details changed in Terragen 2.2 (the introduction of Ray trace atmosphere) and again in Terragen 3 (Ray trace atmosphere renamed to Defer atmo/cloud). This document will be updated soon.
Ray trace objects
If you've spent any time at all rendering plants in Terragen 2.0 you know that it's difficult to get really high quality images without very long render times. It was not uncommon to use anti-aliasing settings of 10 or more and still want for smoother, crisper vegetation. With Terragen 2.1 that's all changed.
Terragen 2.1 features an option to render objects in a separate ray traced pass which is combined with the rest of the scene automatically. By "objects" we mean imported objects in TGO, OBJ and LWO formats, the built-in Grass Clump and the built-in Rock object. We've improved the ray tracing engine and implementing some adaptive sampling routines, and the results are extremely positive. Rendering this way will give you higher quality images, and usually this comes with shorter render times for scenes with reasonably detailed objects. If you have many objects in the scene, for example using the populator, you will almost certainly notice big improvements in image quality and speed.
To use this new option, enable Ray trace objects on the Quality tab of the renderer.
The importance of anti-aliasing
With objects rendered in the ray traced pass, one of the most important settings for controlling the quality of your image - and the time it takes to render - is the Anti-aliasing parameter on the Quality tab of the renderer. The square of the anti-aliasing number tells you the maximum number of primary rays that are traced per pixel of the image, or in other words the maximum samples per pixel. An anti-aliasing value of 3 means that up to 9 samples can be taken per pixel; a value of 8 means that some pixels may take up to 64 samples, and this is usually enough for very good images. An adaptive sampling technique is used to avoid taking the maximum number of samples where the sampler detects that the contrast between adjacent samples is below some threshold. This can be an effective way to concentrate anti-aliasing work where it is needed most, to increase quality and reduce the render time. In previous versions, and still with other objects that are rendered with the traditional way, the Anti-aliasing parameter did not have such a great impact on render times unless you set it very high. With Ray trace objects you need to be aware that Anti-aliasing can greatly affect both quality and render time.
Ray trace everything
In addition to Ray trace objects, there is a similar-looking option on the Extra tab called Ray trace everything. For most scenes we recommend that you do not enable Ray trace everything because this can slow down the rendering of other types of objects and reduce their quality. Planet (terrain), Sphere, Plane, Disc and Lake objects all render more efficiently and with higher quality with the default micro-polygon 'rasteriser', and are not optimised for ray tracing. Detail in these objects is reduced for the ray tracing engine so that their shadows and reflections render faster.
For most scenes, we recommend Ray trace objects ON, Ray trace everything OFF. Those are the default settings for new render nodes and new scenes. If you have set a custom default project, we recommend that you update it to include these settings.
More technical details
There are some situations where you may wish to use Ray trace everything. When everything is ray traced, adaptive sampling can improve the image quality by anti-aliasing shaders and atmospheres (including clouds) and, depending on the sampling settings used, concentrate the anti-aliasing wherever the most contrast is detected. This can be an effective way to reduce noise and anti-alias edges only where they occur. Ray tracing also allows clouds and atmospheres to be rendered with volumetric motion blur, whereas the micro-polygon rasteriser only projects the static atmosphere onto a micro-polygon and then blurs the micro-polygon. Bear in mind that these improvements in quality don't come for free; the renderer has to sample the shaders more times per pixel than it usually would with the micro-polygon rasteriser, so higher quality usually comes at the expense of longer render times. Depending on various factors, however, ray tracing may allow you to reduce the overall render time for an equivalent level of quality.
We can think of three reasons why ray tracing everything may sometimes allow you to reduce render time. Firstly, the ray tracer does not have the problem of overdraw that sometimes happens with the micro-polygon rasteriser, and this can make a big difference in some scenes with mountain ranges which are accidentally drawn back-to-front where front-to-back would be best (this is due to the very simple sorting algorithm used when subdividing polygons in the default renderer, which sometimes does not sort as well as it should). Secondly, surfaces which are viewed at glancing angles, such as terrain or water near the horizon, tend to have micro-polygons that appear smaller than a pixel even thought they would appear much larger if they had been facing the camera. This level of detail is maintained so that important displacements are not missed, because the renderer doesn't know in advance how flat the surface will be. In these areas the surface shaders and atmosphere/cloud shaders might be sampled much more often than in other parts of the image, whereas the adaptive ray tracer treats all parts of the image in the same way. Thirdly, because the level of sampling can adapt to the amount of contrast it detects on a per-pixel or per sub-pixel basis, it is often possible to use lower values for various other render settings that are usually chosen to reduce noise or aliasing of various kinds. For example, a cloudscape might be smooth in most areas of the image and extremely noisy in others. With the micro-polygon rasteriser, the most common way to reduce the noise is to increase the Num samples parameter on the cloud layers or atmospheres, but the extra samples are wasted on the areas that have no noise and they take longer to render. If, instead, the cloudscape is rendered as part of the ray tracing pass, the adaptive pixel sampler will likely reduce the noise overall by tracing more rays per pixel than the micro-polygon rasteriser would, and if the settings are chosen well it will concentrate more rays in the noisier areas.
It is tempting to use lower quality settings in the clouds and atmospheres and let the adaptive pixel sampler solve all noise problems, but in practice this is not always the best strategy. It is often better to adjust cloud and atmosphere settings to give acceptably noise-free results in most of the image with very low anti-aliasing/pixel sampler settings, and allow the adaptive sampler to step up one or two levels for a relatively small area of the total image. In some cases, however, it is possible to take advantage of high pixel sampling levels. Images which need to be heavily sampled for other reasons - e.g. detailed vegetation - may render to a high quality with lower-than-expected settings in the cloud and atmosphere nodes simply because most pixels are sampled more often. Similar observations can be made with other sampling settings such as those for soft shadows.
Ray trace everything is therefore worth considering for renders that do not contain any terrain, such as skyscapes and waterscapes, or for atmosphere passes which are to be composited with other passes afterwards.
If you use Ray trace objects or Ray trace everything, the quality of your image strongly depends on the Anti-aliasing parameter. In effect this parameter is like a preset that controls the parameters of the adaptive pixel sampler. You don't need to know exactly how these parameters are affected by the anti-aliasing preset; we've selected good presets so that you don't need to think about it. However, if you want precise control over the adaptive sampling this is possible by editing the Render Pixel Sampler node. To edit the Render Pixel Sampler, press the Edit Sampling button on the Quality tab of the renderer.
(The Render Pixel Sampler is a node containing the parameters for the adaptive pixel sampler. It is contained in the internal network of the Render node. It is safe to delete a Render Pixel Sampler node, but another one may be created with default settings the next time an image is rendered or you press the Edit Sampling button. You should not create additional Render Pixel Sampler nodes as this may result in unexpected behaviour.)
Render Pixel Sampler parameters
Pixel noise threshold is used for adaptive sampling (adaptive anti-aliasing), unless you set the first sampling level to "Max samples (non-adaptive)".
As an example, let's say you have anti-aliasing set to 4, which gives you a maximum of 16 samples per pixel, and set first sampling level to "1/16 first samples". This gives you a minimum of 1 sample per pixel when max samples is 16. The maximum and minimum number of samples per pixel is shown just below the main anti-aliasing parameter. The minimum samples per pixel depends on the maximum samples and the choice of first sampling level. It also says "mean" next to the number because it may not always be the same for each pixel, due to odd spacings explained later.
In the above example, first off, Terragen takes one sample per pixel. For every four pixels, it looks at the difference between the luminance of those pixels and the luminance of the average of those pixels. This is a way to estimate how much noise or contrast there is in this region. If the total difference is greater than the pixel noise threshold, then that pixel is subdivided into four sub pixels. The process continues with the subpixels, comparing sets of four samples at a time and deciding whether to further subdivide.
The actual threshold used to decide whether to subdivide to the next level depends on the spacing between the samples in the current subdivision level compared to the size of a pixel. At deeper subdivision levels (more samples), the allowable threshold is higher (making it less likely to subdivide) because at higher subdivisions each of the samples has less contribution to the pixel result and we want to help the algorithm stop subdividing as soon as possible. (The maximum samples will never be exceeded, however.) In the same way, if the first sampling level is more coarse than 1 per pixel, the actual threshold used on the first level will be lower than the value entered.
If you choose settings that show that minimum samples per pixel are less than 1, this means that the spacing between the first samples will be larger than a pixel. If you have anti-aliasing at 1, and the first sampling level is "1/4 first samples", this means that there will be only one first sample for every four pixels, i.e. a spacing of 2 pixels. The same would also be true of anti-aliasing 2 with "1/16 first samples". You can make the first sampling level even coarser than this. Generally only useful for low quality previews, but nice and fast.
This all makes sense if you have anti-aliasing levels that are powers of 2, e.g. 1, 2, 4, 8. These correspond to maximum samples of 1, 4, 16, 64. The spacing between samples at all levels of the adaptive process will be powers of 2. However, because Terragen's anti-aliasing levels allow you to use odd values, sometimes the samples of the first sampling level will not fall on exact pixel spacings, which is why you sometimes see non-whole numbers for the mean minimum samples per pixel.
Sometimes these odd spacings degrade image quality or introduce artifacts, especially with motion blur. However, in most static renders there are no noticeable problems, and it's quite useful to be able to choose AA levels between the powers of 2 levels. Many other adaptive ray tracers restrict their sampling to powers of 2. If this concerns you, choose anti-aliasing levels 2, 4, 8 or in extreme cases 16.
The luminance values and the differences between them are actually measured in a non-linear colour space so that dark parts of the image don't appear noisier than bright parts.
Currently the adaptive sampler only keys off luminance, rather than the individual RGB components. Samples that have different hues or saturation values but give the same "luminance" will be seen as being equal, so high amounts of noise in colour and saturation may be tolerated by the sampler. This is often OK, because human vision is also less sensitive to high frequency changes in these things. It also means that the most noise is allowed in the blue channel, and the least in the green channel, due to the weightings of these values in the luminance calculation. There are many situations where this approximation isn't good enough, however, so we will add options to change this in future versions.
A parameter is an individual setting in a node parameter view which controls some aspect of the node.
A single element of an image which describes values for color and/or intensity, depending on the color system which the image uses. Groups of ordered pixels together form a raster image.
A 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.
A 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.
This is essentially the brightness of the colour. Terragen converts RGB colours to greyscale by taking the luminance of the colour.