Hi everybody, who carefully read the previous two tutorials on GI theme and got to the third one! :)
If you are still not one of those lucky enough to be acquainted with the previous parts, we sincerely advise to do so. In particular, you surely must get known with the general concept of GI and its concrete realization in the Brute Force and Irradiance Map algorithms.
In this tutorial, we will learn about the GI bounces rendering algorithms Photon mapping and Light Cache. Also, we’ll study in detail the working principle and each function of Light cache, as well as learn about the optimal values of its settings.
This tutorial answers the following questions:
- What a photon map is and how it works?
- What are the disadvantages of using the photon map?
- How does a modified photon map algorithm Light cache work?
- What is a cell of Light cache?
- How can Light cache store direct light and calculate the diffuse reflections?
- How and why do the Light cache filters work?
- What is the difference between Pre-filtering and Filtering?
- What are the values in the Light cache settings that provide the most acceptable result?
is an outdated rendering engine, the basic concept of which is that the light source bombards all scene objects by portions of energy called photons. After that, being formed a so-called photon map, that is three-dimensional map of photon’s contact points with surfaces. The each point stores information about the brightness and color of the indirect illumination. In general, such map is similar to a map, which obtained by Irradiance map algorithm.
Principle of Photon mapping is easy to understand comparing it to the Irradiance map work.
In the Irradiance map, global illumination map creation begins with that the camera is directing vector, which is getting to the point of the scene, and verifies the source of light that may illuminate this surface. That is, we can assume that the rays are emitted from the camera itself, by checking what other rays from the direct or indirect source of light travel to this point. This way, the calculations are performed only the areas of the scene, which are directly visible from the current camera angle. In its turn, Photon mapping algorithm acts more rough. In addition to the directions of the vectors from the camera itself, it additionally sends the vectors from all sources of light, which are called photons, to all surfaces and literally calculates all the points of the scene, thereby irrationally wasting processing power. This algorithm scatters a scene with photons, even in places that are not visible from camera angle, and even in those that may never be visible from the camera in the case of animation, for example.
Moreover, the Photon map algorithm is not provided with the sufficient adaptability with respect to detail the scene, resulting their poor quality.
Photon map can generate artifacts in the form of dark boundaries of objects, which is one of its main drawbacks.
However, in practice the most significant drawback of Photon map algorithm is its absolute inability to calculate the illumination from the indirect sources of light. Photon map can emit photons only from traditional sources of direct light. For example, it would not perceive the light from the self-illuminating VRayLightMtl material, GI Environment (skylight) or VRaySky map. This makes Photon mapping completely useless when rendering an exterior scene or interior scene with using of the Skylight portal mode of VRayLights.
The only argument in the defense of the Photon map algorithm, which some 3d old-timers still propagate, is its relative physical correctness. It lies in the fact that the general Photon map algorithm can correctly calculate diffuse reflections that actually is the GI, the mentioned in the previous tutorial effects of caustics and even subsurface scattering by oneself.
However, due to a set of limitations and irrationalities, outdated Photon map GI algorithm should not be used in V-Ray at all. It was popular in earlier versions of V-Ray and was used as the engine for Secondary bounces before the onset of a much more advanced and appropriate algorithm Light cache.
Light cache is the original high-tech rendering engine, that is similar by technique of global illumination mapping to the Photon map and at the same time, is its opposite by the rays calculation method. The essence of calculation method is that the Light cache (hereinafter - LC), produces a set of rays from the camera, forming a map of global illumination at the intersection points of these rays with the objects of the scene. These rays are not rays of global illumination and they are not rays, in fact, they just called so. They are the paths from the observation point to the scene. The LC ray, falling on the scene object, calculates the color at the point of contact, taking the properties of materials and light falling on it from sources of direct or indirect light.
Comparing LC with Photon map, it should be noted that LC is deprived of all the major flaws of its predecessor. LC considers only those areas in a scene that are visible from the camera. It copes well with small details and does not create a darkening at the edges of objects. And, most importantly, Light cache is able to work with all light sources, including sources of indirect illumination.
In the first Calculation parameters area of the V-Ray:: Light cache rollout, are the settings that directly affect the calculation of the LC.
Described further recommendations on the specific parameters values are correct only for LC, used as a Secondary bounces GI engine. More information about the choice of GI engines, read in next tutorial.
Subdivs is a parameter that determines the number of LC rays, traced from the camera toward the scene to determine the samples color.
LC algorithm conventionally separates the scene into portions similar to mosaics cells. After that, it determines the color of each of them by sending there LC rays, traced from the camera. That is, each cell is an indivisible color sample that will be used in the resulting GI map.
Of course, the greater the number of rays determined by the parameter Subdivs, the greater number of them will be "fired" to one cell and the more accurate will be determined each cell’s color. The actual number of LC rays equals to the square of the Subdivs value, as well as for other functions using the identically named in V-Ray parameter.
Typically, the value 2000 – 3000 for Subdivs is more than enough for the final rendering of photorealistic images. However, in the starting V-Ray configuration, the set 1000 Subdivs value should be used and it can be raised only when this is necessary.
Sample size determines the size of cell samples. When the cell size is specified, the LC algorithm divides whole image on them. After that, it traces rays to determine the color of each cell. To determine the color of the cell at least one ray is required. Let us assume that the total number of rays determined by Subdivs is less than the total number of cells. Then the LC algorithm will be forced to paint some of the adjacent cells in one color, which visually looks like increasing the size of some cells. In other words, we can say that the visual size of the cells also indirectly dependent on the value of Subdivs. The size specified by the Sample size value will be achieved only if the scene will have sufficient number of LC rays. In the case if LC rays number is greater than the total number of cells, some cells will be calculated by several rays of the LC and will have more accurate color, which will improve the final rendering quality.
The cells size changing should be done only if the scene contains a large number of small details and LC map is insufficiently detailed for their correct representation. In most cases, nominally assigned a Sample size value equal to 0.02 is sufficient for most scenes. That it should be used in the nominal configuration of V-Ray.
Scale is a parameter in a form of drop-down list that allows us to specify the units of cell size. There are two values, Screen and the World.
Screen allows us to specify the value of cell size in the fractional ratio of the final image. For example, if Sample size is 0.02 and the Scale is set to Screen, then it means that each cell will occupy 2% of the entire screen, etc. It should also be understood that the cell size, set relatively to the screen, does not depend on image size in pixels, and the geometry of the scene. That is, in a scene shown in the picture above, the cell size on the front face of the cube and on the wall behind him will be the same size, despite the fact that geometrically, these surfaces are at different distances from the camera.
The World value of Scale parameter makes LC to use for defining the cell size the system 3ds Max units, set for this scene in the System Unit Setup. With this approach, cell sizes are geometrically identical, but visually their size relatively to camera depends on the geometry of the scene. In this case, in the scene shown on the image above, the sizes of cells on the wall behind the cube will be visually smaller than the size of cells on the front face of the cube. Also, considering that LC sampling every part of the image with fixed number of rays, the fewer LC rays get to smaller cells, compared with bigger cells. This will worsen the quality of the sampling of smaller cells. At the final rendering, it may appear as noise or artifacts in fine details of the scene.
The ability to set LC cell samples in system scene units created in order to obtain homogeneous LC maps for the further saving them to a hard drive and use in fly-through animations. This technique is applied in order to be able to render LC for the animation and have identical sizes of LC cells in all the frames, relatively to the scene geometry, regardless of the position of the camera.
For rendering the static scenes, as well as dynamic animations, when the LC map for each frame is calculated individually and cannot be used for the collection of frames, we must use the Screen mode. This will reduce the number of unwanted artifacts. That is the Screen value of Scale parameter should be used for LC in universal V-Ray settings.
Number of passes is the number of passes of LC calculation. Nominally, calculation of LC is not a multi-threaded process; however, it can be intentionally divided into a number of passes (parts) to fully load all the threads of multicore or multiprocessor systems. For example, if LC calculation is performed with the quad-core processor, we can to not break the LC on the passes, that is, set the Number of passes equal to unity. Then, during rendering of LC will be used only one core of a quad-core processor, and the remaining three will be idle, not participating in the calculation of LC. Therefore, to accelerate the LC rendering, it should be forcibly divided to the number of passes, a multiple number of available to system threads. As for today (Feb 2011), the number of cores in most available computer systems does not exceed eight. For example, eight cores available in a system with two quad-core Xeon processors in a dual processor motherboard. For most systems, a nominal set Number of passes value equal to 8 will be the best and that is what is used in the universal start V-Ray configuration.
Store direct light is a feature that allows the LC algorithm to save not only information about the GI, but also information about the direct light in the scene. As we know, LC traces rays from the camera to the scene objects. After crossing the ray with the object scene, the algorithm checks shader of object to determine its color, and continues to trace a ray from that point to the light source, illuminating this object, to determine the brightness. In other words, the LC algorithm in the performance of its working principle has to check also a direct the light that falls on calculation point. That is, it originally gathers information about direct light in the scene as well. Enabling Store direct light allows us to cache, i.e., save this information about direct light of the scene. Traditionally, after the rendering GI render element, V-Ray calculates separately the direct illumination of the scene. Sampling of scene direct light surely requires computational resources and takes time. Caching of light, i.e., previous storing information about it from the LC and the further use of readily available speeds up the final rendering, saving direct light calculation algorithm from the computational content. It is easy to imagine the quality of the thus obtained direct light. It will be much worse than the traditional sampling and will depend on the quality of the LC. This approach is justified only in very overloaded scenes with lots of light sources, where the direct calculation of the light takes many hours. Again, calculated this way images will have significant flaws, clearly betraying the computer-generated image origin. They will be dull with soapy and fuzzy shadows. In the photorealistic rendering, such an approach is not justified, even taking into account the substantial savings of computing resources. In nominal starting configuration of V-Ray, the feature Store direct light should be off.
Show calc. phase is an excellent, in some sense, an irreplaceable feature that lets us to display quite informative preview of the rendered image at the first minutes of the rendering. This eliminates the agonizing test renders at low resolutions and helps to easily adjust lighting and materials of the scene, without waiting for all stages of final rendering. Be sure to use it when setting up your scenes. Of course, this function should be used in universal V-Ray settings.
Adaptive tracing is a feature that allows us to use additional information about lighting in the scene for each LC sample and add more rays in places with lots of light. In some cases, it helps to eliminate noise in the LC, for example, if a scene has caustics. However, it takes memory resources. On the Adaptive tracing parameter work also affects the function Use directions only, which is active only in the case when the first is enabled. In practice, these functions do not make a noticeable improvement in most scenes and in the starting V-Ray settings they should not be activated.
Next in the V-Ray:: Light cache rollout is the Reconstruction parameters area, which contains a few settings, responsible for post-processing of a calculated LC map, for using it in the final rendering images.
Pre-filter is a function that is responsible for interpolation of LC cell samples among themselves. Pre-filter interpolates the available LC sample map to obtain a more smooth result. Only then, it passes the map on to the final image rendering. The power of interpolation is determined by the numeric value next to the Pre-filter. Larger values give less noisy but more blurry results, what consistently leads to the disappearance of small parts and the appearance of "flying chairs". Small Pre-filter values give detailed LC map; however, due to weak smoothing of its samples, it can be very noisy.
Filter is a drop-down list that allows us to select an additional interpolation algorithm of LC map in the final rendering. As mentioned earlier, V-Ray, after calculating the LC, passes the calculated LC map to the final rendering algorithm. Using the LC filter allows us to make an additional interpolation of LC on the final rendering stage. Once LC passed the map to the final rendering algorithm, the last begins the calculation of the shading points (the unit of rendering). If we select one of the filters (not to be confused with the Pre-filter), then when calculating each shading point, the final rendering algorithm will interpolate information from the LC sample map.
None is the Filter drop-down list item, which eliminates the use of LC filter. In this case, the final rendering algorithm will use the LC map as it is, without additional filtering.
Nearest is LC filter, used to interpolate a given point in the LC map with a certain number of nearby samples. Number of nearest samples involved in the filtration is determined by parameter Interpolation samples.
Fixed is filter similar to Nearest, with the only difference that the number of samples involved in the modification of a given point on the GI map, is defined by a square area centered at this point. The size of this area is determined by the value of the Filter size parameter. Units of Filter size depend on the unit value of samples given by the parameter Scale in the area of Calculation parameters, described earlier.
It is worth mention the fact that the filter Fixed calculates and modifies only the area that fall into a zone of Filter size. They look like squares with information about the scene secondary light, while other areas this filter leaves intact, which looks like a black background.
In order to avoid such significant artifacts on the LC map, we should always keep the size of these zones greater than the size of samples themselves, at least twice.
However, using a filter Fixed is justified only in the case of animation rendering and Sample size, measured in system scene units, that is with Scale set to Screen. In other cases, nominally it is worth using Nearest filter.
According to the work principles of the Pre-filter and Filter, it is clear that they in result perform the same function. They smooth (interpolate) the LC map, making it more uniform. These mechanisms differ only in the technical implementation. Pre-filter algorithm interpolates all samples at once for the entire LC map. However, its drawback is that it is single-threaded process, and regardless of the number of threads available to the system, it will use only one thread. At the same time, the Filter algorithm is calculated more accurately, because it occurs separately for each portion of the rendering. This approach requires more computational resources, making the V-Ray every time to calculate the interpolation for each portion of the rendering. Nevertheless, the process of Filter work, as well as final rendering, is multi-threaded and uses all available to system threads through which the computing load is distributed. For single and dual-core systems is rational the use of Pre-filter or a combination in the form of Pre-filter + Filter, where the number of samples interpolation is distributed to half or even with a great pass in to the pre-filtering. Most high-performance graphics workstations and even a gaming PCs are capable of treating four or more physical or virtual threads simultaneously. For them, it would be justified the using of the Filter algorithm. This rationality is particularly useful in distributive rendering, when in calculating a single image simultaneously multiple computers participate.
In the universal V-Ray settings, we should use only Filter: Nearest with the Interpolation samples set to 10. This algorithm and such degree of interpolation will give good not blurred detailed global illumination without evident artifacts.
Use light cache for glossy rays is an option, which lets to calculate diffuse reflections and refractions on the material objects in the scene, using the LC. It allows us to save computing resources. Is to be expected that the quality of calculated this way surfaces will be considerably lower than the direct calculation algorithm. The final rendering quality will depend on the quality and blur of LC map. As is in the case with a similar by goal Store direct light option, the information obtained when calculating the indirect illumination, also contains that information, which can be used in the calculation of diffuse reflections. Of course, the scene materials, calculated this way will look blurred and mess; that is just unacceptable for photorealistic rendering. Little influence on this situation can be achieved through a strong overstatement of LC settings to get relatively good Hilight glossiness and Refraction Glossiness in scene materials. However, then it will be a question of saving time and it will be especially important in distributive rendering. Unfortunately, at this moment in V-Ray, LC map cannot be calculated using the potential of the distributive rendering. Even in a network computing, the time of Light cache rendering will not differ from time of the rendering on a single computer.
Therefore, in starting configuration of V-Ray, the option Use light cache for glossy rays should not be used, for a nominal exclusion of flaws and artifacts associated with its use.
The last two sections of LC settings are the Mode and On render end. They are similar to previously described functions of the same name in IM and will be studied in a separate tutorial dedicated to animation. In the universal starting V-Ray configuration it is worth keeping them as they are by default, there is nothing in them should be changed.
In this tutorial, we met with two GI rendering algorithms, namely Photon mapping and Light Cache and looked into the most important aspects of the last one’s work. In particular, we exhaustively learned all details, aspects and tweaks of GI rendering engine Light Cache, and were able to see clearly everything on numerous examples.
Dear friends, we sincerely hope that after carefully reading this lesson, you are much closer to understanding the essence of the Photon map and Light cache. We also hope that you are now feeling free to use a lot of settings of the LC and are familiar with every function name. Understanding of this critical information allows easily configuring and getting of the great GI maps for photo-realistic 3d renderings.
In the next tutorial, we will define with the choice of the optimal combination of render engines for primary and secondary GI bounces. We will analyze in detail what rendering algorithm should be used as Primary bounces GI engine, and which as a Secondary bounces GI engine. In addition, we will finally close the question about how to get rid of the dark spots on cornices.
All have easy settings and beautiful 3d renderings!