Difference between revisions of "Ray Trace Objects and Defer Shading"
m (Matt moved page Ray Trace Objects and Defer Atmosphere/Cloud to Ray Trace Objects and Defer Shading)
(→The importance of anti-aliasing)
|Line 33:||Line 33:|
== The importance of anti-aliasing ==
== The importance of anti-aliasing ==
When objects or deferred , 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''', '''Defer atmo/cloud''' or '''Defer all shading''' you need to be aware that '''Anti-aliasing''' can greatly affect both quality and render time.
== Ray trace everything ==
== Ray trace everything ==
Latest revision as of 09:19, 5 November 2019
This document was originally written for Terragen 2.1 and has been updated to make it more relevant for Terragen 2.5, Terragen 3 and Terragen 4.
Ray trace objects
If you spent any time at all rendering plants in Terragen 2.0 you know that it was 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 all changed.
Terragen 2.1 and newer versions feature an option to render objects in a separate deferred render pass which is combined with the rest of the scene automatically. By "objects" we mean imported objects in TGO, OBJ and LWO formats, and the built-in objects Card, Grass Clump and Rock. We 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 by rendering with the new method.
To use this option in Terragen 2 and 3, enable Ray trace objects on the Quality tab of the renderer. In Terragen 4 it is on the Advanced tab and should usually be enabled.
In Terragen 2.2 we introduced an option called Ray trace atmosphere. In Terragen 3 we renamed this to Defer atmo/cloud. This separates the rendering of all atmospheres and clouds into the deferred render pass, the same pass that is used for ray tracing objects. This produces higher quality images of clouds and atmosphere by combining them with the same adaptive sampling engine that is used for ray tracing objects, although it can be enabled even when Ray trace objects is not. The higher quality results of Defer atmo/cloud sometimes come at the price of longer render times, but there are many cases when you should use it. In some cases it can turn out to be faster simply by enabling it on scenes that are complex, particular if they have a lot of vegetation that covers the ground and sky. In other cases, very often it is possible to achieve equivalent quality results in a shorter time if other atmosphere and cloud settings are adjusted well for deferred atmosphere/cloud rendering.
When rendering with Ray trace objects, atmosphere and clouds that are visible in the subpixels of the ray traced objects are always rendered as part of the ray traced objects, so Defer atmo/cloud doesn't affect those particular subpixels. It only affects atmosphere and clouds that would otherwise have been rendered as part of the micropolygon shading of any surfaces that are rendered with the micropolygon rasteriser. This usually includes terrain (planet), sky (background sphere), water (lake) or any other displaceable object type. However, some of those micropolygons might be calculated even if they are hidden behind ray traced objects, so enabling Defer atmo/cloud can avoid calculating the atmosphere/clouds for these hidden pixels and is one reason why it sometimes produces faster renders.
Defer atmo/cloud brings consistency in the way that the atmosphere and clouds are rendered across the whole image, regardless of micropolygon detail or whether or not objects are ray traced.
More pros and cons are discussed in the "More technical details" section below.
Defer all shading
Beginning with Terragen 4.3, Defer all shading is a great way to improve anti-aliasing of textures and lighting on the terrain and other displaced surfaces. It unifies adaptive anti-aliasing across all parts of the scene. In some cases it will render faster, and in others it will render slower, but in most cases image quality is better. Image quality and render time depend on anti-aliasing settings.
Defer all shading uses the same idea as Defer atmo/cloud but applies it to the evaluation of surface shaders and lighting on all surfaces. Atmosphere, texture and lighting are all calculated in the deferred render pass, the same pass that is used for ray tracing objects.
When Defer all shading is enabled, the atmosphere and clouds will render with the same quality as Defer atmo/cloud and that checkbox will be ignored.
More pros and cons are discussed in the "More technical details" section below.
The importance of anti-aliasing
When ray tracing objects or doing any kind of deferred shading, 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, Defer atmo/cloud or Defer all shading you need to be aware that Anti-aliasing can greatly affect both quality and render time.
Ray trace everything
There is yet another option on the Extra tab or Advanced 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
When everything is ray traced or all shading is deferred, 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 or deferred atmo/cloud rendering also allow 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.
In Terragen 2.2 and higher you can get most of these benefits to your atmosphere and clouds by enabling Ray trace atmosphere (Terragen 2.2) or Defer atmo/cloud (Terragen 3 and 4).
In Terragen 4.3 and higher you can get all of these benefits by enabling Defer all shading. This is much faster than Ray trace everything.
We can think of three reasons why ray tracing everything (or using deferred atmosphere/cloud/shading) 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 deferred render 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.
When using Defer atmo/cloud, Defer all shading or Ray trace everything, 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.
If you use Ray trace objects, Defer atmo/cloud, Defer all shading or Ray trace everything, the quality of your image (or parts of it) 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.)
For more information refer to Render Pixel Sampler.
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.