Basics of global illumination

From Kray
Jump to: navigation, search

Basics of global illumination

Global illumination is a general name for a group of algorithms used in 3d computer graphics that are meant to add more realistic lighting to 3D scenes. Such algorithms take into account not only the light which comes directly from a light source (direct illumination), but also subsequent cases in which light rays from the same source are reflected by other surfaces in the scene (indirect illumination).

Images rendered using global illumination algorithms often appear more photorealistic than images rendered using only direct illumination algorithms. However, such images are computationally more expensive and consequently much slower to generate. One common approach is to compute the global illumination of a scene and store that information with the geometry, i.e., radiosity. That stored data can then be used to generate images from different viewpoints for generating walkthroughs of a scene without having to go through expensive lighting calculations repeatedly.

Radiosity, ray tracing, beam tracing, cone tracing, path tracing, metropolis light transport, ambient occlusion, and photon mapping are all examples of algorithms used in global illumination, some of which may be used together to yield results that are fast, but accurate.

(source: http://en.wikipedia.org/wiki/Global_illumination)

Global illumination techniques in Kray

Kray can use several of these techniques – Raytracing, Photon/Light mapping and Path tracing. Raytracing computes only direct illumination while Photon mapping, Light mapping and Path tracing compute full global illumination in a scene.


Photon mapping

Photon mapping is one of the techniques which help speed up the calculation of GI dramatically. It consists of two steps: shooting photon and final gathering. In the first step a specified number of light packets called photons are fired from a light source and bounced around the scene. Whenever a photon intersects with a surface, the intersection point, incoming direction, and energy of the photon are stored in a cache called the photon map.

You can see photons in Kray by using Photon estimate mode Global unfiltered.


Global unfiltered


Photon mapping is only a rough approximation of a light at any given point. Therefore we need another step to get more accurate result.

Final Gathering

The final step in rendering that Kray does is called Final Gathering (or FG).

This technique computes a more accurate illumination at a sampled point. It uses the photon map that was computed in the previous step to help speed up the process. Computing irradiance for every point in space may still be slow therefore it uses another technique called irradiance caching to speed up the process. What irradiance caching does is, it only computes irradiance at points where light is most likely to change - for example in corners, in place of shadows, where two surfaces are near each other, etc.). Where surface is large and flat it uses less points to save a time. Kray finds these points by doing a pre pass before final render called prerender.

You can see where Kray is computing FG by selecting Photon mapping mode with cache irradiance and turn on show samples in FG tab.

Samples.jpg


You can also turn irradiance caching off in the main tab by unchecking cache irradiance button. This might be useful in difficult light conditions where cached irradiance gives a lot of errors (splotches) which don't go away even by increasing number of FG rays.

Photon mapping and irradiance caching can be saved to a file and be reused for another frame. So in an animation you only have to compute FG for those points that have not yet been computed (that have not been seen by camera in previous frames).


Links for more in depth knowledge:

http://en.wikipedia.org/wiki/Photon_mapping

http://web.cs.wpi.edu/~emmanuel/courses/cs563/write_ups/zackw/photon_mapping/PhotonMapping.html

Path Tracing

Path tracing is a form of ray tracing whereby each ray is recursively traced along a path until it reaches a light emitting source where the light contribution along the path is calculated. This recursive tracing helps for solving the lighting equation more accurately than conventional ray tracing.