GI and HDR Lighting in Yafray


There are a multitude of ways to light a scene, from a few simple spotlights, through arealights and complex light rigs to different forms of global illumination. Here I will be discussing this latter option, using Yafray for rendering, from inside Blender. First I'd like to address the common misconception that GI is some magic 'make realistic rendering' button. It is simply a type of lighting model that is more advanced than the good old spot lamps, and more physically accurate. It will not automatically make a nice image for you, it will simply give you a head start by being a substitution for a very complex lighting rig with dozens of lamps that would need to be placed by hand. It therefore saves time (and time=money...). It basically gives you a base fill light, with an even light distribution, and a nice natural look. This can (and should) be complemented with traditional lights.

Besides the lighting, the GI rendering algorhythm is also responsible for colour bleeding between objects (hard to fake without GI), and caustics (near impossible to fake). However, GI is slower than raytracing and much slower than scanline rendering, and is therefore only for final rendering for stills. It can't really be used for animations (yet), not only beacuse of time, but because ligth/dark spots are randomly rendered (sampled) and they jump around from frame to frame.

First we'll look at the GI settings for Yafray, and then I'll describe a typical lighting setup that I use for product visualisation.

Global illumination is different from raytracing, in the latter a ray is traced from the camera to an object, this can be reflected/refracted, and then traced to all lights that are visible. This gives you reflection, refraction and (hard) shadows. GI on the other hand traces the path of the photons themselves from the lamps to the objects, bouncing between objects in the scene. This gives you reflection, refraction AND colour bleeding, soft shadows, caustics (impossible with raytracing) and generally a nicer look. The origin of the light in GI can be a lamp, or any object. For outside scenes, the whole backdrop (world) can emit light. Since Blender does not support GI yet, I use Yafray.

GI settings

First, make sure that you have Yafray installed, and its location added to your OS's 'path' variable (see the Yafray readme!). In Blender, go to the render buttons, and in the drop-down list under the large RENDER button, select Yafray. This should open up two extra settings panels: Yafray and Yafray GI. In the Yafray panel, the XML button should be turned off, this allows you to see the render in progress. The two buttons below allow you to specify the antialiasing. The other buttons below these aren't important now, they don't need to be changed. The other panel: Yafray GI is more important. The Method drop-down list allows you to select either None for no GI, SkyDome for a method similar to Blender's Ambient Occlusion, and Full for the proper global illumination rendering. Selecting Full will open up new buttons on the bottom. The Quality setting will determine the (guess what!) quality as well as speed of the render, a setting of medium/high should be enough for most situations. If there are small faces, detailed models, or surfaces very close to each other, you might need to set the quality higher to get rid of render artifacts.

A complete GI solution can be painfully slow to render (hours), so some tricks can be used to speed it up. Turn on both the Cache and the Photons buttons in the Yafray GI panel. The photon cache will speed up the render over ten times! However, it will lead to some bright/dark spots on the final render. Increase the Quality to get rid of these, or change the Ref button. If you set the "Ref" (refinement) to anything other than 1 (I use 0.1), it will calculate the photon map two times before the final render. The second pass does more calculations in the parts of the picture that have more detail, and the final result will therefore be better.

The other important settings are: EmitPwr and GI Pwr. The emitpower determines how bright emitting objects, arealights and the background are. GI power determines how much "energy" (light) these emitters will emit. It is usually enough to change the GI Power setting to make your scene darker or brighter.


To use GI, you need to have some light emitters in your scene. Light emitters in Blender/Yafray can be the following: arealights, objects with a material Emit value more than 0, and the background. The simplest thing to do is set the background to any colour that isn't black. The background will emit from all directions evenly, similar to an overcast day outside. You can also load a HDR light probe, which determines what coloured light comes from which direction.

Product Visualization I - "White Space"

foldable wine storage on white background

Now, lets try some lighting! I will use a scene I did not too long ago, it is a design for a fold-up wine holder. You can see the final image here, it is for product visualization. Therefore the most important part of the image is the product itself, and nothing else should be present to draw the viewers' attention away, not even a background scene. This is one of my favourite setups, for lack of a better term I called it "white space", the product is on a completely white ground, with a white background, yet it doesn't just float in space, but has shadows. It looks very good printed on paper, as well as in any document or other white background (a webpage for example), creating the impression that the object itself is sitting there on the paper.

If you look closer, you can see there are two types of shadow here. The hard shadow comes from a sun light, but you can use any other type of light that casts shadows. NOTE: except arealights! Arealights act as photon emitters when GI rendering in Yafray, and not as normal lights! The nice soft shadows are the result of GI.

The scene

simple setup with one sun lamp

The scene, besides the product itself, is simply a white plane, and a sun lamp, nothing more, very simple.

The ground

Settings: R,G,B=1.00, Ref=1.00

The white plane doesn't extend too far, just far enough to catch all the shadows of the objects. It is completely white, and the Reflectivity is 1.0. Note that the option "Only shadow" doesn't work with Yafray. This means the edges of the plane would be visible in the final render, which is not good! That is fixed in the render settings, see below.

The light

Energy=0.6, ray shadow enabled

There is only one light in the scene, a sun lamp with Raytraced shadows turned on. It is slightly yellowish in colour, with a power of 0.6.

The World

HoR=0.94, HoG=0.93, HoB=1.0

Very simple again, the world is one coloured, a very slightly blueish white.

Render settings

EmitPwr 1.2, GIPwr 0.8, AA enabled

VERY IMPORTANT! It is really lame, and I have seen bad examples of it many times, when a product is showcased on a grey plane, floating in space, or at least on some sort of background. This grey plane shouts CGI. It's important that you can't see this base plane, it should blend into the background. In this example I used a white plane, but even a white plane sometimes is rendered grey at the edges. The background itself is slightly blue and not white. So the trick to have this "White Space" effect is to set the EmitPwr in the Yafray GI settings above 1. It takes some experimentation for the right settings, so that you can't see the edge of the base plane, but it doesn't glow in an unnatural way either. A setting of 1.20 seems to work well. GI power is 0.80. If you make the sun lamp brighter, then decrease these settings, if its darker then increase these.

Make some low resolution test renders. Click and hold the left mouse button on the render, this will show the colour of the given pixel in the bottom left corner. Drag the mouse around, and make sure that both the background, and the base plane is R: 255, G: 255, B: 255. Then you're ready for the high res final render! Make sure to set the quality to Medium or High, the Ref value to something other than 1, and turn on Antialiasing, in this example I used 2 passes with 4 samples each, this is the setting I usually use, it is a good quality/speed tradeoff. And see how much quality we have achieved with a very simple setup!

Product Visualization II - HDR Ligthing

sample HDR light probe

Instead of a plain white-ish world colour, you can set a High Dynamic Range light probe for the background. This will vary the light colour and intensity across the virtual sky, making a more natural, smooth look. To clarify the two terms: HDR means high-dynamic range image, where instead of RGB values from 0 to 255, floating point numbers with better precision, and a higher "dynamic range" are used to store the luminosity (light emission) of each pixel. Light probe means the image is a complete 360-degree panoramic picture of the environment. The process of making HDR light probes is outside the scope of this tutorial, so I will just say either download one of the several HDR probes available on the net (see for some starters), or make your own. Make sure it is in the light probe format (aka. angular map), as opposed to: vertical cross, latitude/longitude, or some other panoramic format.

This next step can be skipped, but I highly recommend it. The problem with GI illumination with Yafray is that for a a fast rendering, it uses some random samples of the environment. A nice and sharp HDR image can have differing light values in a short interval, ie: too much contrast. With just a few samples, some samples will fall onto a very bright pixel, and some will fall onto a nearby darker pixel, and this will result in a "spotty" render. I solve this problem by blurring the original HDR map. From, you can download HDRShop v1 for free. Open your light probe, and in the Filters menu, select Gaussian blur, and blur the image, using a value of 4-5 for smaller maps: 512 x 512, to 12-15 for higher resolution maps, like 1512 x 1512. Resave it with a different name.

Loading the HDR probe

AngMap enabled, Hori, ZenUp, ZenDown enabled.

Go to the texture buttons, and select the green "World" button. Set texture type to Image, and load the *.hdr file like any other image. Go to the world button, and in the Map To panel, set mapping to Angular map, and the output to Hori, ZenUp and ZenDown. Yafray will automatically see that you have a HDR world texture, and when GI is turned on, it automatically uses that image for lighting.

Scene setup

Big curved plane under object

Similar to the previous example. The base plane is not enough however, as you will see its edge in the render. To fix this, make the farther end of the plane curve up into the air, high enough to block all of the camera's filed of view. Make sure this curve starts farther than the shadows of the object, otherwise you will see the shadow curve up unnnaturally into the air.


The "White Space" method above had a completely uniform white light, which means the sun lamp used for the additional hard shadow could be placed anywhere. However, most HDR probes have one or more concentrated light sources. First render the scene with only the GI lighting and no lamps. See which way the soft shadows are cast, and then position the sun lamp accordingly. You might need several test renders to get the hard shadow pointing the right way. I usually use very subtle, weak light(s) with HDR maps, the energy should be around 0.2-0.4, not more.

Render settings

Similar to the first method, except for the GI Power setting. This can vary a lot with the given HDR map you are using, depending on how bright it is. Do some low res quick renders to find the right brightness. Some darker maps need 1-1.5 at the most, while the brighter ones might only need a GI Power of 0.2. And then comes the final render! Here is my test scene with a sunset HDR probe made with Terragen. This same quality without GI would need a few dozen lamps, all set up properly, so we clearly see the advantages.

Wine storage with coloured lighting

Not only do HDR maps provide the base lighting of a scene, but they also provide a realistic environment the objects can reflect. They can also be the background, however most HDR probes are too low-res to provide a nice background image. Instead, it is preferrable to use a photo of the original location for a background. This test image shows one of my own probes in action, along with a photo background taken at the same location. Note that instead of a grey plane which screams CGI, I used a stone pedestal, making it blend in better.

Susanne with HDR lighting

This was just one small portion of what you can do with global illumination, you can also use it for indoor scenes, try placing emitting planes or arealamps in your scene. For caustics, add "photon lamps", which are available in the Lamp settings in Blender. Experiment. Have fun!