|
Table of Content: |
In real life, objects are lit by several types of lighting. For instance, light casted from lamps and light bouncing from other nearby objects. Besides, some materials, such as glass, can modify the behaviour of light. Other lighting effects are color bleeding between adjacent surfaces and light scattering in participating media. The interaction and sum of all these effects produce a global result that is called global illumination.
Raytracers try to reproduce global illumination (GI) by means of techniques that follow light natural behaviour, such as casting samples of rays that bounce in the scene observing realistic rules. Those samples are computed so a general result can be extrapolated from a limited amount of rays. Theorically, there are more than one way to achieve this, each way with its own share of advantages and shortcomings. There isn't such a thing as a perfect GI model, and new algorithms are created for solving the incovenients of already existing techniques.
YafaRay has got a traditional raytracing method which only renders light cast from light sources, called Direct Lighting. Additionally, YafaRay has got three different Global Illumination models, which are Path tracing, Photon Mapping and Bidirectional Path tracing. Below you have a comparison between Direct Lighting (left) and a Global Illumination model, in this case Photon Mapping (right). Notice the differences between them:
![]() |
![]() |
A certain amount of borrowing is possible between these lighting methods, since they are more or less based on the same 'ray' concept. So it is possible to implement the same averaging technique in different GI methods, or mix features from different models. This is the case of caustic photons option in Direct Lighting, for instance.
Direct Lighting |
Path Tracing |
![]() |
![]() |
How it works:Direct Lighting only performs recursive raytracing. Primary rays are shot from the camera and intersect with the scene. Then secondary rays are generated but just towards light sources, to calculate shadows. They're also called shadow rays. Primary rays can be transmitted in reflective and refractive surfaces. Advantages:
Disavantages:
|
How it works:Rays are shot from the camera. Each bounce casts a lot of secondary rays. Some of them eventually reach a light source. Then the light contribution along the path is calculated. Advantanges:
Disavantages:
|
Photon mapping |
Bidirectional path tracing |
![]() |
![]() |
How it works:Rays (photons) are cast from light sources and bounce around, regardless of the camera. A photon map is created, based on photon hits. Then, a standard raytracing pass is performed to visualise the photon map. Advantages:
Disavantages:
|
How it works:Ray paths are constructed from the camera and from light sources. Bounces are connected to each other with visibility rays. Advantages:
Disavantages:
|
|
Related articles: |
|
GI algorithms are born with shortcomings and compromises in order to solve very specific raytracing problems. There isn't such a thing as a universal lighting algorithm for all cases. In fact, the only method that can be used for all cases is Direct Lighting. In the next paragraphs we are going to explain use cases in YafaRay, and what are the best lighting methods for them.
Open scenes means that the scene is not enclosed by a mesh, and the background can work as a main light source. Open scenes can be used to simulate studio lighting and indoor scenes as well, by using a suitable scene composition and/or a HDR indoor image as a background. The recomended methods for open scenes are:
|
Comparison between Direct Lighting and Pathtracing used in an outdoors scene. Notice indirect light calculations and soft color bleeding effects in Path tracing. |
![]() |
| Direct lighting + Ambient Occlusion, render time 42 s. |
![]() |
| Direct lighting + Sunsky Skylight, render time 518 s. |
![]() |
| Path tracing + Sunsky Skylight, render time 1205 s. |
|
Related articles: |
Enclosed scenes means that the scene is inside a mesh (thickness for walls recommended), which is good for some ray bouncing. This enclosing mesh can have windows to simulate a houseroom. The recommended methods for enclosed scenes are:
| Comparison between different lighting methods, rendered on a Pentium IV. Notice lack of color bleeeding in Direct Lighting. Photon mapping is the fastest GI method, and Bidirectional the slowest one. Notice how the two unbiased methods (Path tracing and Bidirectional) struggle in indirect lighting areas (noise). Bidirectional produces the brightest indirect lighting result and more color bleeding than the other GI methods. | |
![]() |
![]() |
| Direct lighting + AO + Cphotons. 0:1:35 |
Photon mapping. 0:9:10 |
![]() |
![]() |
| Path tracing + Cphotons. 0:15:20 | Bidirectional. 1:32:18 |
|
Related articles: |
|
Ambient Occlusion is a shading method that takes into account attenuation of light due to object occlusion. Ambient occlusion is most often calculated by casting rays in every direction from a point on a surface. Rays which reach the background or “sky” increase the brightness of the surface, whereas a ray which hits any other object contributes no illumination. As a result, points surrounded by a large amount of geometry are rendered dark, whereas points with little geometry on the visible hemisphere appear light.
![]() |
Ambient oclussion is often used as a fast approximation of the indirect lighting produced gy Global Illumination models. It is also used as an independent pass for render post-processing, usually with Clay render enabled. |
AO settings are:
|
|
| Related articles: Use cases | |
Caustics is a concentration of light, produced by refractive medium (glass, water) and by curved specular surfaces (mirror, glossy and fresnel). It is possible to produce independent caustic photon maps in YafaRay. This option is available in lighting methods that either can't render caustics (Direct Lighting) or aren't efficient at this kind of task (Path tracing). Caustics add realism and they are relatively cheap to compute. The caustics photon map is visualized directly and this is the reason why the number of photons in the caustics photon map must be high, since a high resolution map is needed.
Mix and Radius are two limit parameters to blur the caustic map. Photon hits will be averaged within a circular area. The center of each circular area is defined by camera rays. If there isn't enough photon density within the circular area, low frequency noise will appear. Those circular areas will use whatever limit is reached first, either Mix or Radius. Many times incremental changes in a limit won't have any blur effect since the other thresold has been already reached.
Below are two of examples of caustics:
|
|
| Example of refractive caustics, using as photons source a spot light. Scene by MarcoA |
![]() |
| Example of reflective caustics, using a caustic photon map in pathtracing. The HDRI background is the caustic photons source. Scene by Sevontheweb. |
Caustic photon maps work better and more efficiently with concentrated light beams directed towards the 'caustic' surface, using a spot light. Caustic settings are:
|
Related articles: Materials that can produce caustics: |

Path tracing is a GI unbiased method in which each ray is recursively traced from the camera along a path until it reaches a light source. When a light source is found, the light contribution along the path is calculated, taking into account surface properties. Many samples are need to be taken and interpolated for each camera pixel to get a smooth result. A light source can be either a lamp, the scene background or both. Scenes with relatively small light sources and with a high contrast between light sources and their surrounding areas will need more samples to reduce noise. The smaller and less accessible the light sources are, the more noise will appear. Pathtracing is a GI solution more suited for outdoor scenes and for indoor scenes with big light sources (area lights or big windows) and a regular distribution of light.
Pathtracing caustic paths tend to be very noisy and a very big amount of samples is needed to get a smooth result. In YafaRay we have four alternative methods to render the caustic component when pathtracing is used:
This is an example about how methods for the caustics component work in pathtracing. In the first image (upper left), Path is used to get caustics, which are very noisy when a low number of samples is used (16). In the second render, 512 pathtracing samples are used to improve path traced caustics, but it takes much more render time (38 minutes). In the third example, Photons are used to produce the caustics component and the render time is the lowest of them all (Cm stands for Caustic method):

Area light types (sphere and area) with the Make Light visible option enabled produce caustics in Path caustic mode. More information about the caustic photon map settings can be found in the previous section (they are the same)
|
Related articles: |
The other components of the global illumination model are rendered as usual. Other pathtracing settings are:
| It is a good practice to increase & decrease your 'samples' settings in base 2 steps (2-4-8-16-32-64-128... etc) |
|
Related articles: |
![]() |
Photon mapping was developed as an efficient alternative to path tracing, since certain effects are more efficiently simulated with sampling from lights (caustics, indirect lighting) while some others effects are more efficiently sampled from the camera (mirror reflection, direct lighting). |
Photon mapping is a two pass technique:
Photon mapping is biased, the average values might not be correct, but it is consistent: with more photons and less radius, it converges to a correct solution. Photon map produces low frequency noise (big patches) in contrast with path tracing, which produces high frequency noise (pixel-level). |
|
Photons propagate flux. They are emitted by light sources and stored in the photon map when they hit a surface. In fact, each emitted photon can be stored several times. The photon map represents the incoming illumination, also called Irradiance (incoming radiance). Two photon maps are produced in fact, which are:
In general, the more photons are used, the more accurate is the lighting estimate, but increasing photons increases time to build the photon map. If the number of photons is too low, the irradiance estimation becomes blurry at the edges of sharp features in the illumination, for instance fast transition from light to shadows in corners.
However, in simple scenes with no caustic effects, it is possible to produce relatively good results with very low density maps of 1000-2000 photons. In this case the photon map is rendered very quickly. Below a comparison between two photon mapping cases with different photon counts, notice the bad estimation below the horizontal prism and below the sphere, in the render on the left:
![]() |
![]() |
| 2000 Photons, Depth=2, 213 seconds. | 1.000.000 photons, Depth=10, 290 seconds, |
Depth controls amount of consecutive bounces for both caustic and diffuse photons. However, it has got a different meaning depending on photon type:
Comparison between different values of Depth, with the same number of photons shot. Photon hits means the number of photons recorded in the photon map, which is a value shown in the back console. Notice the relatively small difference in hits between depth=10 and depth=50. Almost equal render times in all cases. Scene by Kronos:
![]() |
| Photon Depth=3, photon hits= 410.000 |
![]() |
| Photon depth=10, photon hits= 610.000 |
![]() |
| Photon depth=50, photon hits=650.000 |
The second pass is a traditional ray tracing pass performed by shooting rays from the camera. Based on a single photon, we can not say how much light a region receives. This information is thus provided by the photon density. When a ray hits a point P on a surface, the illumination information of the neighboring photons is collected and interpolated at P. We don't need a photon for every polygon, but instead a few photons to estimate the incoming flux in the region around P. The photon density is higher in areas with strong incoming illumination.
A well chosen radius allows for a good pruning of the search. Two radius are used to perform the search of neighboring photons, whichever is reached first:
In general, Radius should be inversely proportional to the number of photons shot: the more photons the less diff. radius. However, a too low radius wihout an adecuate photon density, introduces noise (small patches). Radius settings are one of the main factors in render times. If the number of photons to look up and average increases, so does the render times.
|
Note: When using photon mapping in enclosed scenes such as house rooms, it is important that objects follow realistic techniques for modelling, such as closed meshes with real thickness. Follow this advice in walls, floor, ceiling and furniture. In this way we avoid estimation problems when searching for neighboring photons. |
|
Related articles: Materials that can produce caustics: |
Final gather is a caching technique to improve and 'complete' photon mapping by gathering, after photon tracing, an approximation of the local irradiance by using several illumination bounces. This information is used at render time for further interpolation, with the obvious advantage of requiring a less accurate and therefore faster, but yet physically correct, photon map. Noise reduction in FG renders depends on FG samples and anti aliasing settings.
|
Related articles: |
![]() |
Bidirectional constructs rays from the camera and from light sources, and connect each others' bounces with visibility rays to ensure they are mutually visible. It is more efficienct than pathtracing for caustics and indoor lighting, but variance show up as noise too. |
Sampling of the bidirectional rays is performed by using antialiasing settings, which means that you'll need a big amount of antialiasing sampling. For instance, 16 AA passes x 16 AA samples would mean that 256 bidirectional samples are used. Another strategy is using an extreme amount of AA passes x AA samples, and stopping the render process when it is clean enough. The more AA sampling, the more convergence to the correct solution.
AA threshold must be 0 to sample all pixels in every pass. The proportion between AA passes and AA samples is irrelevant in this case for noise removal, since the whole image is resampled in every pass. Therefore, only the multiplication result matters, the higher the amount of samples, the less variation and the more noise reduction. However, having all samples in one pass will likely be faster than having many passes with one sample each. Rendering a small problematic portion of the image with border rendering (Shift+B) will give you an idea about how the result converges and the amount of sampling needed for the whole render.
|
Related articles: |