LIGHTING METHODS

LIGHTING METHODS

Table of Content:

Illumination Types.

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 tracingPhoton Mapping andBidirectional 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.

Lighting Methods Overview.

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 calledshadow rays.

Primary rays can be transmitted in reflective and refractive surfaces.

Advantages:

  • Very fast in scenes where indirect lighting is not needed.
  • Can render independent caustic photonmaps and ambient oclussion.
  • HDR backgrounds (IBL, Sunsky) can work as light sources, simulating indirect lighting.

Disavantages:
  • No indirect lighting.
  • Can't render caustics (you'll need to enable caustics photonmap).
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:

  • It performs Global Illumination.
  • Fast in outdoors, because paths find the background easily.
  • Unbiased, delivers correct results.
  • Soft indirect lighting if enough sampling.

Disavantages:
  • Variance shows up as noise.
  • Lot of rays are needed for caustics.
  • Inefficient in indoor scenes, when light sources are too hidden or too small.
  • Doesn't like omni lights (spot, point) and mirror surfaces. Better use area light types and glossy. 

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:

  • It performs Global Illumination.
  • Fast, efficient GI estimation in indoors.
  • Best quality/speed ratio.
  • Fast caustics.

Disavantages:
  • Not well suited for outdoors
  • Sometimes requires photon map tweaking.
  • Artifacts.
How it works:

Ray paths are constructed from the camera and from light sources. Bounces are connected to each other with visibility rays.

Advantages:

  • It performs Global Illumination.
  • Combine advantages from path tracing and photon mapping.
  • More efficient than path tracing for indoors and for caustic effects.
  • Unbiased, delivers correct results.
  • Good for scenes with lot of indirect lighting.

Disavantages:
  • Variance shows up as noise.
  • Not well suited for outdoors.
  • Inefficient in indoor scenes, when light sources are too hidden.

Related articles:

Use Cases.

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:

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:

  • Direct lighting. It delivers fast results and you can use area light types (area, sphere, mesh) to achieve soft shadows.
  • Direct lighting + AO + caustics photons. Fast. If you have refractive and/or reflective surfaces in the scene you can enable caustic photons, it adds realism. Use this 'combo' for fluid animations as well.
  • Direct lighting + IBL with a HDRI texture. HDR images can work as light sources in Direct Lighting. Fast for outdoors, when indirect lighting can be simulated with background lighting. HDRI backgrounds can shoot caustic photons as well.
  • Direct lighting + Sunsky. Components of the Sunsky model (Sun and Skylight) work as light sources. Fast for outdoors, when indirect lighting can be simulated with background lighting. Sunsky can shoot caustic photons as well.
  • Path tracing + background (HDRI, Sunsky, Gradient, Single Color). Fast because many pathtracing rays can find a light source (background) after the first bounce. Use it if you need color bleeding or if you want a precise simulation of the indirect lighting.

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:

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:

  • Direct lighting. Use it for traditional lighting setups and studio lighting, if you don't need the indirect lighting component. You can use area light types (area, sphere, mesh) to achieve soft shadows. To simulate indirect lighting, many times photon mapping will be faster than a complex rig of fill lights.
  • Direct lighting + AO + caustics photons. Fast. If you have refractive and/or reflective surfaces in the scene, enable caustic photons, it adds realism. Use this 'combo' for fluid animations as well.
  • Photon mapping + FG. A good fast GI algorithm for all indoor cases, it isn't afraid of complex lighting cases.
  • Bidirectional path tracing. It works well if there is an optimal situation of light sources. For instance, if light sources can be seen from the camera or from the first bounce of camera rays. Use it in scenes with lot of indirect lighting and/or if you are looking for a correct simulation of the Global Illumination.
  • Path tracing. The least efficient method for indoors. Use it if there is an optimal situation of light sources (see bidirectional) and an even distribution of lighting, for instance scenes with big windows or big area light sources. You'd better use area lights (area, sphere, meshlight) rather than omni lights (spot, point) in path tracing.
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:20Bidirectional. 1:32:18

Related articles:

Animations:

  • Direct lighting + caustics photons. Fast for indoors, even faster with omni lights (point, spot). Caustic photon maps are compatible with frame rendering (no caustics flickering). HDR backgrounds optional (IBL, Sunsky), with caustic photons.
  • Path tracing + background lighting. With adaptive sampling, it can produce fast results in open scenes.
  • Photon mapping + FG. If indirect lighting is needed and the scene is enclosed, PM+FG is the fastest Global Illumination algorithm for animations. It's compatible with both frame-based animation and portion-based distributed rendering. You will need a good and well balanced photon map to avoid shadows flickering though.

Related articles:

Parameters

Ambient Occlusion

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 renderenabled.

AO settings are:
  • AO Samples: The number of rays used to detect if an object is occluded. Higher numbers of samples give smoother and more accurate results, at the expense of slower render times
  • AO Distance: The length of the occlusion rays. The longer this distance, the greater impact that far away geometry will have on the occlusion effect. A high Dist value also means that the renderer has to search a greater area for geometry that occludes, so render time can be optimized by making this distance as short as possible, for the visual effect that you want.
  • AO Color: Color for ambient occlusion rays. Use this setting to control AO power.
Related articles: Use cases

Caustic photon map

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 byMarcoA
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:

  • Photons: Number of photons to shoot. Increases photon map density and render times.
  • Caustic Depth: amount of reflective or refractive events for caustic photons.
  • Caustic Mix: amount of photons to mix (blur). The more photons to search for, the more render time.
  • Caustic Radius: area of photons to mix (blur). The more photons to search for, the more render time.

Related articles:

Materials that can produce caustics:

Path tracing.

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.

Path tracing caustic component

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:

  • Path+Photon: a mix of a caustic photon map and path tracing caustic rays are used.
  • Photon: a fast photon map is used to render caustics. Path tracing caustics rays are not rendered.
  • Path: Path tracing caustics rays are rendered.
  • None: the caustic component is not rendered.

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:

Path tracing settings

The other components of the global illumination model are rendered as usual. Other pathtracing settings are:

  • Depth: defines the number of rays bounces in order to find the light sources. Higher raydepth produces brighter renders. In scenes with big light sources, like open scenes using background lighting, a high raydepth could be unnecessary. This setting controls depth of pathtracing caustic rays as well.
  • Samples: This setting defines the number of samples to take per camera pixel, the more samples the better render quality and the less noise, but the longer render time as well. The relation between noise reduction and sampling isn't linear: to halve the noise, it is necessary to use four times as many samples. The total amount of Path tracing sampling depends as well on anti-aliasing settings, as explained in this section.
  • Use background: Makes use of the background as a light source. Sunsky models and IBL lighting work always as light sources, regardless of this setting.
  • No recursion: only path tracing is performed without recursive raytracing, which means that shadow rays are not traced.
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

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:
  • The first pass is photon tracing, which consist in building the photon map by tracing photons from lights. It calculates indirect lighting and caustics effects.
  • The second pass consist in raytracing the scene (camera rays) using the information in the photon map. This second pass calculates specular reflections (mirror & glossy) as well.

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

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:

  • A low density photon map for diffuse surfaces called Global photon map.
  • An independent high density map for caustic effects.

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

Depth controls amount of consecutive bounces for both caustic and diffuse photons. However, it has got a different meaning depending on photon type:

  • Depth for Caustic photons: Amount of consecutive refractive and/or reflective events for caustic photons, until they reach a diffuse surface.
  • Depth for Diffuse photons: Amount of bounces in diffuse surfaces. More depth will produce more color bleeding and a denser photon map. Beyond certain point the amount of depth will have a limited effect in map density or color bleeding, since most photons will be already absorbed by diffuse surfaces.

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
Radius

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:

  • Diff. Radius. The sphere of fixed radius improves the estimation slightly, but fails in scenes with high variation of density of photons. It gives bad estimates if there are too few photons and blurry estimates when there is a high density of photons.
  • Search. User can specify a desired number of photons. It guarantees that there are K photons in the measurement. The more photons are used, the smoother the estimation will be. If too many are used, the estimation will tend to be blurry, while too few gives a splotchy appearance (low frequency noise). Interpolating 50 to 150 photons is often a good choice.
  • Caustic Mix: Number of photons to mix, produces blur in the caustic photon map.
  • Use background: The way it works depends on the background used:
    • With Single ColorGradient and non-IBL Texture, the background works as a light source if this option is enabled. Use FG & AA sampling to remove noise.
    • IBL Texture and Sunsky work always as a light source, regardless of this option. However, when it is enabled, photons hitting the background will not be discarded but get energy from it. As a result, scenes will have more lighting power from the background than when this option is disabled. Use BG & FG & AA sampling to remove noise.

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

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.

  • FG bounces: in a precomputed phase, determines the number of bounces for Final Gather rays. The first bounce is the most important one; subsequent bounces have got a more modest impact on the result.
  • FG samples: Final Gathering samples for interpolation, the more the better, but the longer it will take to render. The total amount of Final Gather sampling depends as well on anti-aliasing settings, as explained in this section.
  • Show map: Useful to tune the photon map. When using it, you must seek for results with a soft uniform appearance of patches, without noticeable groups of darker patches regularly distributed across surfaces, which is a hint of low-frequency noise. When you have problems of density there are two options, increasing number of photons shot and bounces, or increasing radius settings. A good well-balanced photon map is especially important for animations.

Related articles:

Bidirectional Pathtracing

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值