Back to tutorials index
Getting started guide
Important
This tutorial was written for Blender 2.32 release. It maybe is obsolete in some points, but we think it could be still useful.
The GI panel
At a first glance the GI panel appears like this. Just two select boxes. The first one selects the illumination method.
- Skydome: Just light from the background, no inter object lighting
- Full: Full GI. Indirect lighting included. So objects light each other
The second select box is the quality level. This is a set of pre-settings to avoid giving a concrete sample number. Level ranges from
low to
best. The export code will set the number of samples based on this level for both skydome (
hemilight) and full (
pathlight).
Skydome
For skydome, the simplest method, only power and quality level are needed. Power both on skydome and full acts as a multiplier for the diffuse light power coming from the background and emitting objects. In the concrete case of skydome only background affects lighting.
Full method
If we choose full method, a set of new controls appears. First of all, the light maximum depth (upper right)
Depth. This is the maximum number of times light will bounce off objects to get indirect lighting.
Below it we find
CDepth. This is the caustic bounce limit. When getting caustic effects, more bounces are needed to go through glass objects and reach some light source.
With this method, caustics can only be casted by non-point light sources. This means that from background and emitting objects, we have to wait for another release to export caustics from a spot light. But of course one can always edit the resulting xml file and set it up by hand.
Another two checkbuttons serve to activate
cache mode and
photon mapping.
Cache mode
For a tipical outdoor scene like this, no photons are needed. The light source is just a big visible sky. But cache mode can help to speed up and smooth the render (no noise).
The available settings for cache mode are:
- ShadQu: Shadow quality, irradiance samples are increased when close to other objects following this value. The higher, the more samples will be taken near a shadowing object. The default value 0.9 is good enough for most scenes.
- Prec: Pixel precision. At least one irradiance sample is taken each X pixels of distance. You can imagine a grid of samples (X spaced), that would be the irradiance sample distribution if we had just a plane. A value of 10 is good for high res images (1024x768). At lower resolutions sometimes a lower prec value (8) helps to improve the quality of the image.
- Gradient: This is a not very good scheme to smooth the shadows. Not very useful now with refinement available.
- Refinement: YafRay has the ability of refining the shadows once a first result is taken (after the first render pass). This is a threshold value. If we set it to 0.2, light steps of more than 0.2 (intensity) are refined (antialiased) taking more irradiance samples. It's quite similar to the common pixel selective anti-alias but applied to light values all over the scene. A scene like this does not need shadow refinement, but we will see examples where it is very useful.
Using photons
Photons are just a helper for the full GI method. When the light source is small (a spot light or a small arealight), is quite hard for pathlight to find it by random bouncing off the scene, so noisy results or blotchy for cache mode appear very often. This is thought for the tipical indoor scene where there's no big visible sky, but a window, or a lamp, or an arealight. Sometimes the sun comes through a window or just from the background outside (soft lighting). That's what we'll try to solve here.
The cornell box
We will set up a common
_cornell box_, with an area emitter as a lamp in the ceiling. We do this by puting a plane and assigning it a white material with
emit=1.0. This is a very small source as you see, so we will help YafRay by putting a quad arealight just in the same place as the emitting object. A bit lower to avoid the plane shadowing photons.
This arealight we have just put there will tell YafRay that there is light coming from that place, so it will shoot photons from it to help the lighting. We have to set the arealight color to the same color of the emitting object, white in this case. It is very important for you to do this or you could get strange results. Next step is to tune the photons ...
Tuning photons
We go back to the GI panel and check the
photons button. A new set of params will appear.
- Count: Number of photons, a higher number makes a smoother result, for this scene we can try with 200000.
- Radius: This param is more important. Photons will be blurred according to this radius, so you have to find a good value for your scene to keep a good precision / smoothness balance. For this one, a radius of half of the small box size is a good starting point.
- MixCount: The number of photons you want to keep inside that radius. Together with radius these two settings determine the photonmap resolution. Keeping here values of 100 or 150 works almost in every scene. You'll see it easily in the tune picture below.
So now we check the
Tune Photons check button to see if the photon map is good enough, see below.
The resulting photonmap
After a fast render with
Tune Photons checked, we get a direct visialization of the photon map. This is not the final result. This is an aproximation of the global lighting in the scene. If you get a result like this:
It is good enough as a photon map for pathlight, you don't need to tweak it anymore. Since the source is very small, we have to set the GI power very high (35) to get this amount of light. Remember that
Depth value explained at the beginning determines the amount of bounces. This one is made with
Depth=3.
When should I improve it
If you get a very very blotchy result, you can either increase the photon count or increase the mix radius. If the "clouds" are very small, then increasing the radius will blur further and smooth them out. But if the clouds are big, increasing it will disolve the shadows too much. In this case increasing the photon count is the best solution.
Final Result
Now, with cache mode activated, a quality of
higher, default settings except for refinement value which I set to 0.05 to refine the nice shadows which appear in this scene, we get this picture:
Look at the caustics on the floor coming from the arealight and also from the red wall. We set
CDepth to 3 to let light pass through the glass ball.
Other examples
We will see now how other kind of pictures can be done. The other kind of indoor scene where light is coming from a window, like this:
Here the light is coming from the background that we can see through a big window on the right side. You can see it reflected in the ball.
To render this picture with a smooth result in a reasonable time, we have to tell YafRay that light is coming from that window. Almost the same way we did with the cornel box, but this time with the window.
As you see here, we place the quad arealight to match the window shape. Exactly the same place, but it doesn't matter if you don't match its shape perfectly. In the case of a circular window you would just place the arealight a bit outside to cover all the window.
Now YafRay knows that light is entering by that window or hole, and photons will by shot from there. The rest of the setup is quite similar to the cornell example. But for this one we don't need so high quality settings. A quality of
medium and a refinement of 0.1 is enough for this one.
Hard sun or lamps
This topic will be covered more in depth in future docs. But the idea with a bright sun coming from a window is similar. We emulate it with a spot light that we place lighting through a window or hole like this.
Photons will be shot in that cone from the spot into the scene. As for the rest is the same process we did with the area emitters.
You can also place the spot light inside of a room to emulate a lamp.
Expect more info about Blender / YafRay GI setup in future docs.
Download these examples
*
Examples
Back to tutorials index
to top