©Anton Podvalny

Introduction


In this chapter, we'll begin the large topic of Global Illumination (GI) - a key part of the photorealistic rendering process. It's important to understand the inner working of the GI algorithms in order to be able to come up with good parameter values for your scenes. First, we'll cover briefly all algorithms, their advantages and disadvantages, their parameters and a comparison between them. After that, we'll delve into more detail about the four algorithms.


Overview of the different approaches


Brute Force

This is the simplest approach; indirect illumination is computed independently for each shaded surface point by tracing a number of rays in different directions on the hemisphere above that point.

Advantages:

  • This approach preserves all the detail (e.g. small and sharp shadows) in the indirect lighting.
  • It is free from defects like flickering in animations.
  • No additional memory is required.
  • Indirect illumination in the case of motion-blurred moving objects is computed correctly.
  • The GI calculations can be distributed over multiple machines using Distributed Rendering (DR).

Disadvantages:

  • The approach is very slow for complex images (e.g. interior lighting).
  • It tends to produce noise in the images, which can be avoided only by shooting a larger number of rays, thus slowing it even more.


Irradiance Map

This approach is based on irradiance caching; the basic idea is to compute the indirect illumination only at some points in the scene, and interpolate for the rest of the points.

The Irradiance Map is a legacy method and the users are not advised to use it.

Advantages:

  • The irradiance map is very fast compared to direct computation, especially for scenes with large flat areas.
  • The noise inherent to direct computation is greatly reduced.
  • The irradiance map can be saved and reused to speed up calculations of different views for the same scene and of fly-through animations.
  • The irradiance map can also be used to accelerate direct diffuse lighting from area light sources.
  • The GI calculations can be distributed over multiple machines using Distributed Rendering (DR).

Disadvantages:

  • Some details in indirect lighting can be lost or blurred due to the interpolation.
  • If low settings are used, flickering may occur when rendering animations.
  • The irradiance map requires additional memory.
  • Indirect illumination with motion-blurred moving objects is not entirely correct and may lead to noise (although in most cases this is not noticeable).


Light Cache

Light caching is a technique for approximating the global illumination in a scene. It is very similar to photon mapping but without many of its limitations. The light map is built by tracing many eye paths from the camera. Each of the bounces in the path stores the illumination from the rest of the path into a 3D structure, very similar to the photon map. The light map is a universal GI solution that can be used for both interior and exterior scenes, either directly or as a secondary bounce approximation when used with the irradiance map or the brute force GI method.

Advantages:

  • The light cache is easy to set up. We only have the camera to trace rays from, as opposed to the photon map, which must process each light in the scene and usually requires a separate setup for each light.
  • The light-caching approach works efficiently with any lights - including skylight, self-illuminated objects, non-physical lights, photometric lights, etc. In contrast, the photon map is limited in the lighting effects it can reproduce - for example, the photon map cannot reproduce the illumination from skylight or from standard omni lights without inverse-square falloff.
  • The light cache produces correct results in corners and around small objects. The photon map, on the other hand, relies on tricky density estimation schemes, which often produce wrong results in these cases, either darkening or brightening those areas.
  • In many cases the light cache can be visualized directly for very fast and smooth previews of the lighting in the scene.

Disadvantages:

  • Like the irradiance map, the light cache is view-dependent and is generated for a particular position of the camera. However, it generates an approximation for indirectly visible parts of the scene as well - for example, one light cache can approximate completely the GI in a closed room.
  • Currently, the light cache works only with V-Ray materials.
  • Like the photon map, the light cache is not adaptive. The irradiance is computed at a fixed resolution, which is determined by the user.
  • The light cache does not work very well with bump maps; use the irradiance map or brute force GI if you want to achieve better results with bump maps.
  • Lighting involving motion-blurred moving objects is not entirely correct, but is very smooth since the light cache blurs GI in time as well (as opposed to the irradiance map, where each sample is computed at a particular instant of time).
  • The GI calculations cannot be distributed over multiple machines using Distributed Rendering (DR).
  • Which method to use? That depends on the task at hand. The Examples below can help you in choosing a suitable method for your scene.


Parameters


By default global illumination (GI) is disabled in an empty scene (with the exception of Interactive GPU mode where you can't disable GI). You need to set SettingsGI::on to 1 to enable tracing of secondary rays. Any photorealistic render needs GI, so apart from some kind of debugging, you will always want to enable GI.

Other SettingsGI parameters of interest are:

  • primary_engine - The primary GI bounce engine. We don't recommend using Photon Map for either primary or secondary. The possible values are 0=Irradiance Map, 1=Photon Map, 2=Brute Force, 3=Light Cache.
  • secondary_engine - The secondary bounce GI engine. The possible values are the same as for the primary engine, with the exception of Irradiance Map - if you set this to 0 it will disable secondary bounces.
  • ao_on, ao_amount, ao_radius - Keep in mind that ambient occlusion (AO) is not a physically correct/accurate way to get shadows. If you enable ambient occlusion with ao_on, ao_amount is a multiplier for the strength of the effect between 0.0 and 1.0 and ao_radius defines the hemisphere that is evaluated for occlusion.

We don't recommend changing the contrast and saturation parameters.

The choice of GI engines and their parameters is paramount, especially for interiors where most of the illumination is indirect. Bad choices can lead to too much noise or artifacts and/or disproportionate render time for certain image quality. The common setup for interiors is Irradiance Map with Light Cache secondary and for exterior scenes it is often Brute Force primary with BF or LC secondary.


Brute force

The settings for Brute force are in SettingsDMCGI

  • subdivs - Controls the number of new rays spawned at each intersection point. We recommend using the default value.
  • depth - The number of secondary bounces to trace before stopping. Larger values may increase the brightness of indirect illumination at the cost of render time. The default is 3.
  • adaptivity_prepass – The adaptivity pre-pass computes necessary data for algorithms like path guiding, adaptive lights, adaptive dome light, and auto exposure, similarly to the Light cache method. These features rely on extra training data obtained during the pre-passes. Therefore, this process is necessary for them to function properly when used alongside the Brute force Global Illumination (GI) engine. This option is not supported with V-Ray GPU.


Irradiance map

The Irradiance map is configured through SettingsIrradianceMap. See this page for details on the algorithm and its parameters.

The main two parameters are:

  • subdivs - The default is 50. Higher values can fix spot-like artifacts and lower values should improve render times.
  • interp_samples - The default is 20. Setting a lower value may help if surfaces seem too blurry.


Light cache

The Light cache is configured through SettingsLightCache. See this page for details on the algorithm and its parameters.

There are a lot of parameters for fine-tuning and fixing specific problems but the main parameter is:

  • subdivs - The default is 1000. Higher values can fix spot-like artifacts and lower values should improve render times


Examples

Comparison

Here is a scene rendered with different GI algorithms in V-Ray. Combining the different GI engines allows great flexibility in balancing time versus quality of the final image.

Note that the render time depends on the hardware, build version, and the scene itself. These are general guidelines to help you find the best method for your specific case.


Brute force GI, 4 bounces

The image is darker because only 4 light bounces are computed. Notice the grain and the long render time.

Render time: 1 min 10 sec


Irradiance map + Brute force GI, 4 bounces

The image is darker because only 4 light bounces are computed. The grain is gone, although the GI is a little blurry.

(see the GI caustics below the glass sphere)

Render time: 0 min 24 sec


Brute force GI + Light cache

There is some grain in the GI, but it is a lot faster than Brute force GI alone.

Render time: 0 min 13 sec





Irradiance map + Light cache

Render time: 0 min 7 sec


Irradiance map + Light cache with GI caustics enabled

Notice the slowdown due to the caustics.

Render time: 0 min 8 sec





Light Bounces

This example shows the effect of the number of light bounces on an image:



Direct lighting only: GI is off


1 bounce: brute force, no secondary GI engine


2 bounces: irradiance map + brute force GI with 1 secondary nounce





4 bounces: irradiance map + brute force GI with 3 secondary bounces


8 bounces: irradiance map + brute force GI with 7 secondary bounces


Unlimited bounces (complete diffuse lighting solution): irradiance map + light cache




Brute Force


The brute force method for computing global illumination recomputes the GI values for every single shaded point separately and independently from other points. While very slow, this method is very accurate, especially if you have many small details in the scene.

To speed up brute force GI, you can use a faster method (the photon map or the light map) for approximating secondary GI bounces, while using the brute force method for the primary bounces.

The following diagram shows the way rays are traced when using the Brute Force GI. Since the method is view-dependent, the first rays (Black) are traced from the camera into the scene in order to determine the points for which GI is going to be calculated. Then the Primary bounces (Red) are traced into the scene - the number of rays traced depends on the Subdivs parameter. The Secondary bounce rays (Blue) are traced only when Brute Force GI is used for secondary GI engine. In that case, a single ray is traced for each bounce and the number of bounces depends on the Secondary Bounces parameter.



Parameters

We already covered all parameters in the previous section of this lesson.


Light Cache


Light caching (called "light mapping" in older versions of V-Ray) is a technique for approximating the global illumination in a scene. This method was developed originally by Chaos specifically for the V-Ray renderer. It is very similar to photon mapping but without many of its limitations.

The light cache is built by tracing many eye paths from the camera. Each of the bounces in the path stores the illumination from the rest of the path into a 3D structure, very similar to the photon map. On the other hand, in a sense, it is the exact opposite of the photon map, which traces paths from the lights, and stores the accumulated energy from the beginning of the path into the photon map.

Although very simple, the light-caching approach has many advantages over the photon map:

  • It is easier to set up. We only have the camera to trace rays from, as opposed to the photon map, which must process each light in the scene and usually requires a separate setup for each light.
  • The light-caching approach works efficiently with any light - including skylight, self-illuminated objects, non-physical lights, photometric lights, etc. In contrast, the photon map is limited in the lighting effects it can reproduce - for example, the photon map cannot reproduce the illumination from skylight or from standard omni lights without inverse-square falloff.
  • The light cache produces correct results in corners and around small objects. The photon map, on the other hand, relies on tricky density estimation schemes, which often produce wrong results in these cases, either darkening or brightening those areas.
  • In many cases, the light cache can be visualized directly for very fast and smooth previews of the lighting in the scene.


Even with these advantages, light caching is similar in speed to the photon map and can produce approximations to the global lighting in a scene very quickly. In addition, the light cache can be used successfully for adding GI effects to animations.

Of course, the light cache has some limitations:

  • Like the irradiance map, it is view-dependent and is generated for a particular position of the camera.
  • Like the photon map, the light cache is not adaptive. The illumination is computed at a fixed resolution, which is determined by the user.
  • The light cache does not work very well with bump maps.


The following diagram shows the way the Light Cache is being generated. To get the lighting from the environment, V-Ray traces many rays from the camera into the scene. Each bounce of light creates a sample in the light cache that can be used during the rendering. If one ray hits a sample that was created by another Mode ray, the tracing is stopped and the information from the sample is read instead. This speeds up the process a lot.



Parameters

We already covered the main parameter. Here are the rest:

Calculation Parameters

These parameters affect the calculation phase of the light cache. The light cache generated with these parameters is later used to create the final rendering.

  • sample_size - Sample size when calculating the light cache.
  • world_scale - Determines the units of the Sample size:

    • Screen – The units are fractions of the final image (a value of 1.0 means the samples are as large as the whole image). Samples that are closer to the camera are smaller, and samples that are far away are larger. Note that the units do not depend on the image resolution. This value is best suited for stills or animations where the light cache needs to be computed at each frame.
    • World – The sizes are fixed in world units everywhere. This can affect the quality of the samples - samples that are close to the camera are sampled more often and appear smoother, while samples that are far away are noisier. This value might work better for fly-through animations, since it forces constant sample density everywhere.


For more information, see The Scale Parameter example below.

  • show_calc_phase - Enabling will show the paths that are traced. This does not affect the calculation of the light cache and is provided only as feedback to the user. This option is ignored when rendering to fields - in that case, the calculation phase is never displayed.
  • retrace_enabled - Enables retracing of GI near corners. Normally, this should be enabled.
  • retrace_threshold - Retrace threshold, relative to the light cache sample size. This helps prevent light leaks and flickering. The value specified is the extent to which GI near corners are retraced instead of being read from the light cache. A value of 0.0 disables retracing. A value of 2.0 is good for still images, and 8.0 is good for animations. Higher values result in more rays traced at render time. For more information, see the Retrace example below.
  • retrace_leak_prevention - Enables additional checks to mimize light leaks; 0.0 means no checks. The default value of 8.0 should be adequate for most cases.


Reconstruction Parameters

These parameters control how the light cache is used in the final rendering, after it has been calculated.

  • prefilter - When enabled, the samples in the light cache are filtered before rendering. Note that this is different from the normal light cache filtering controlled by the Filter parameter, which happens during rendering. Prefiltering is performed by examining each sample in turn, and modifying it so that it represents the average of the given number of nearby samples. More prefilter samples mean a blurrier and less noisy light cache. Prefiltering is computed only once after a new light cache is computed or loaded from disk.
  • prefilter_samples - Number of samples to look for when prefiltering the light cache.
  • use_for_glossy_rays - When enabled, the light cache is used to compute lighting for glossy rays as well, in addition to normal GI rays. This can speed up the rendering of scenes with glossy reflections quite a lot. When you use this option, it is recommended to also enable the Retrace threshold option, which prevents the light cache from being visible in very glossy surfaces.
  • filter_type - Determines the type of render-time filter for the light cache. The filter determines how irradiance is interpolated from the samples in the light cache. Possible values are:

    • 0 - no filter - No filtering is performed. The nearest sample to the shaded point is taken as the irradiance value. This is the fastest option, but it might produce artifacts near corners if the light cache is noisy. You can use the Pre-filter setting to decrease the noise. This option works best if the light cache is used for secondary bounces only, or for testing purposes.
    • 1 - nearest - Looks up the nearest samples to the shading point and averages their value. This filter is not suitable for direct visualization of the light cache, but is useful if you use the light cache for secondary bounces. A property of this filter is that it adapts to the sample density of the light cache and is computed for a nearly constant time. The Interpolation samples parameter determines how many of the nearest samples to look up from the light cache.
    • 2 - fixed - Looks up and averages all samples from the light cache that fall within a certain distance from the shaded point. This filter produces smooth results and is suitable for direct visualization of the light cache (when it is used as the primary GI engine). The size of the filter is determined by the Filter size parameter. Larger values blur the light cache and smooth out noise. Typical values for the Filter size are 2-6 times larger than the Sample size. Note that the Filter size uses the same scale as the Sample size, and that the units used depend on the Scale parameter.
  • filter_samples - Number of samples to look for with the 'nearest' filter type.

  • filter_size - Filter size for the 'fixed' filter type.
  • store_direct_light - When enabled, the light cache also stores and interpolates direct light. This can be useful for scenes with many lights when either irradiance map or direct GI (brute force) method is used for the primary diffuse bounces, since direct lighting will be computed from the light cache instead of sampling each and every light. Note that only the diffuse illumination produced by the scene lights is stored. If you want to use the light cache directly for approximating the GI while keeping the direct lighting sharp, disable this option.


Bounces

  • depth - Maximum bounces for the light cache. Leave this to the default value of 100. Note that, because of the way the light cache is calculated, the solution always converges to that of infinite light bounces, regardless of this value.


Mode

  • mode - Mode – Determines the rendering mode of the light cache:

    • Single frame – Computes a new light cache for each frame of an animation.
    • Fly-through – Computes a light cache for an entire fly-through animation, assuming that the camera position/orientation is the only thing that changes. The movement of the camera in the active time segment only is taken into consideration. Note that it may be better to set Scale to World for fly-through animations. The light cache for the entire animated sequence is computed only at the first rendered frame and is reused without changes for subsequent frames.
    • From file – The light cache is loaded from a file. The light cache file does not include the prefiltering of the light cache; prefiltering is performed after the light cache is loaded, so that you can adjust it without the need to recompute the light cache.
    • Progressive path tracing – The light cache algorithm is used to sample the final image progressively.
  • file - File name to save the map to.


On Render End

  • dont_delete - True if the light cache should not be deleted at the end of the rendering.
  • auto_save - True if the light cache should be saved at the end of the rendering.
  • auto_save_file - String


Others

  • num_passes - Number of passes for the light cache. Each pass is rendered in a single thread, therefore it is best to set this to the number of processors.
  • adaptive_sampling - True if adaptive hemispheric sampling should be used. This requires more memory than the non-adaptive light cache.
  • premultiplied - True to use premultiplied light cache when possible.
  • multiple_views - This causes the light cache to be calculated for the entire camera path, even when in single-frame mode.


Avoiding flickering in animations


Since the light cache is a biased GI solution, it can introduce some unwanted flickering in animations. Below are some tips to reduce this effect.

  • For flickering due to an animated camera, for short camera moves, an easy fix is to enable the Use camera path option. To remove flickering for longer camera moves where the camera is the only animated part of the scene, precalculate the light cache using Fly-through mode and then use the saved cache for the entire animation.
  • For interior renders or other complicated lighting situations, increasing the light cache Subdivs parameter makes the light cache smoother and more accurate; values around 2000 or 3000 typically work well.
  • The Retrace option helps to reduce light leaks and flickering. For animations, a value of 8.0 works well.
  • Prefiltering also smooths the light cache and reduces flickering. A Pre-filter value of 20 works well.

Following the above, some suggested settings could look like this:

For animations where the only moving object is the camera, enable the Use camera path option, or precalculate the light cache for the entire animation using the Fly-through mode.

For animations with moving objects and/or moving camera:

  • If the camera is moving at relatively small distances (f.e. within a single room of an interior render), enable the Use camera path option.
  • Set the Subdivs parameter to 3000, Sample size to 0.01, Prefilter enabled and Prefilter samples to 20, Retrace enabled and Retrace threshold to 8.0.


Notes

  • Do not set the Adaptive amount in the DMC Sampler rollup to 0.0 when using the light cache, as this will cause excessive render times.
  • Do not apply perfectly white or very close to white materials to a majority of the objects in the scene, as this will cause excessive render times. This is because the amount of reflected light in the scene will decrease very gradually and the light cache will have to trace longer paths. Also avoid materials that have one of their RGB components set to maximum (255) or above.
  • If you want to use the light cache for animation, you should choose a large enough value for the Filter size in order to remove the flickering in the GI.
  • There is no difference between light caches computed for primary bounces (direct visualization) and for secondary bounces. You can safely use light caches computed in one of these modes for the other.
  • Similar to the photon map, you can get "light leaks" with the light cache around very thin surfaces with substantially different illumination on both sides. Sometimes it may be possible to reduce this effect by assigning different GI Surface ID's to the objects on both sides of the thin surface (see the Object settings dialogue); the effect can also be reduced by decreasing the Sample size and/or the filtering.
  • Using Light Cache with GPU is possible only in Production GPU mode, or with From file mode (already computed Light Cache .vrlmap) in Interactive.
  • The Light Cache calculation cannot be distributed among several machines for distributed rendering.


Examples

The Subdivs Parameter

The Subdivs parameter controls the number of rays that are shot into the scene and the "noise" quality of the light cache samples.

Here is a scene rendered with different settings for the Subdivs parameter (all other settings are the same).

As we add more samples, the noise is reduced, but the render times increase. When the Subdivs parameter is increased twice, the light cache takes approximately 4 times as long to calculate.



Subdivisions = 500

Subdivisions = 1000

Subdivisions = 2000



The Sample Size Parameter

The Sample size parameter controls the size of the individual light cache samples. Smaller values produce a more detailed lighting solution, but are noisier and take more RAM. Larger values produce less detail, but take less RAM and may be faster to calculate.

Here is a scene rendered with different values for the Sample size parameter. All other values are the same.

  • Note the light leak from the wall on the right in the last image – this is because samples from the other side of the wall are quite large and end up being used on the side facing the camera.
  • Note the difference in the noise level between the samples.


Sample size = 0.01

Sample size = 0.02

Sample size = 0.03



The Scale Parameter

The Scale parameter determines whether the Sample size and Filter size parameters are in screen space or world space.

In the table below, the Screen scale was used, and the scene was rendered with different image and world sizes. The Sample size was constant for all images - the default 0.02.

As you can see, we always get the same number of light cache samples for all cases, regardless of resolution or scene size - in fact, when scaled to the same size, the images look identical. This is why the Screen Scale is applicable to the large variety of scenes.

In the table below, the World Scale mode was used. Again, the scene is rendered at three different resolutions and scales, but with the same light cache parameters. The sample size was set to be 1/5th of the sphere radius in the scene at normal scale.

  • You will notice that the number of samples again does not depend on the image resolution, but it does depend on the scene size.
  • Also, notice how the samples near the camera appear larger because of the perspective - in difference from the Screen Scale mode which compensates for this effect and tries to make the samples with more or less equal size on the image.
  • Another thing to note is that we don't get light leaks (compare with sample size example), even when the samples are relatively large - this is because the World Scale forces a uniform sample size on both sides of the right wall.


The Retrace Parameter

The first set of images shows how the Retrace threshold parameter can be used to reduce light leaks due to the light cache interpolation. The scene is an interior scene with parts of the exterior visible.

The bright light cache samples from the exterior blend with the darker samples from the interior causing light leaks when the irradiance map is calculated. The Retrace threshold option (with the default value of 1.0) successfully resolves the problem at the expense of slightly increased calculation time for the irradiance map.

When disabled, corners in the scene produce light leaks and inaccurate shadows. This is visible in the shelving unit and on the ceiling's adjacent wall. When enabled, light leaks are successfully eliminated at the expense of longer calculation time.



Disabled Before image
Enabled After image



The second scene in this example shows how the Retrace threshold option can be used to improve the appearance of glossy reflections and refraction with the Use light cache for glossy rays option. In this case, V-Ray dynamically decides whether to use the light cache or not, based on the glossiness of the surface and the distance from it.


Retrace: Disabled Before image
Retrace: Enabled After image
Retrace: Disabled Before image
Retrace: Enabled After image


Without retracing, the light cache samples are clearly visible in the glossy reflections and refractions.

With light cache retracing enabled, V-Ray is able to dynamically decide whether to use the light cache or not, leading to a much better result.

  • No labels
Was this helpful?