Lights

Relevant to Blender v2.31

YafRay provides several kind of lights:

Spot light

This is fairly similar to Blender's Spot Light


<light type="spotlight" name="spot" power="30.0" size="80" blend="10"
beam_falloff="2" halo="on" res="512" blur="0.0" fog_density="0.20">
  <from x="-0.140436" y="4.175604" z="8.336139" />
  <to x="-0.140436" y="4.175604" z="0" />
  <color r="1" g="1" b="1" />
  <fog   r="1" g="1" b="1" />
</light>
                         
                         

Point light

This is fairly similar to Blender's Lamp... but it casts shadows!


<light type = "pointlight" name= "omniLight" power= "1.000000" cast_shadows= "on" >
        <from x="6.372691" y="3.340035" z="2.815973" />
        <color r="1.000000" g="1.000000" b="0.000000" />
</light>
                         
                         

Pointlight, with Hemilight (white dot represents light position).

Sun light

This is again similar to Blender's Sun... but it casts shadows!


<light type ="sunlight" name="Lamp.001" power="1.000000" cast_shadows="on">
        <from x="0.026929" y="-0.071142" z="3.552329" />
        <color r="1.000000" g="1.000000" b="1.000000" />
</light>
                         
                         

sunlight, with hemilight to provide some diffuse shading

Soft light


<light type= "softlight" name="softomni" power="1.000000" res="512" radius="5.000000" bias="0.300000" >
        <from x="0.026929" y="-0.071142" z="3.552329" />
        <color r="1.000000" g="1.000000" b="1.000000" />
</light>
                         
                         

Area light

This is a light shed uniformly by a quadrilateral


<light type "arealight" name"Lamp.001" power="25.000000" samples="64.000000" psamples="64.000000">
        <d  x = "-2.800729"  y = "-0.566380"  z = "3.235599" />
        <c  x = "-0.686398"  y = "-1.759042"  z = "3.833231" />
        <b  x = "0.541875"  y = "0.418420"  z = "3.833231" />
        <a  x = "-1.572455"  y = "1.611082"  z = "3.235599" />
        <color r="1.000000" g="1.000000" b="1.000000" />
</light>
                         
                         

Arealight, with Hemilight (white dot represents light position).

Path Light

This indirect lighting system performs 'global illumination' by taking light from background and diffuse objects. It uses either a Monte Carlo raytracing algorithm (MC), or a Quasi Monte Carlo raytracing algorithm (QMC). The results from either system can be rendered using an Irradiance Cache.

Since MC uses random sampling the results can be quite noisy. The more samples you take the less noise you'll see. Of course this results in a longer render time. QMC sampling on the other hand produces less noise, but sometimes can result in discernible patterns in the shading of objects. Both noise and patterns can be reduced with yafray built-in Anti Noise Filter.

Path Light will produce nice radiosity effects. It can also produce caustics, however, as the photons that produce the caustics are not focused in a specific direction like the photon light, the caustic patterns will be softer unless a huge number of samples are taken.


<light type = "pathlight" name = "path" power = "1.000000" depth = "2" caus_depth = "4" samples = "16" use_QMC = "on" cache = "on" cache_size = "0.008000" angle_threshold = "0.200000" shadow_threshold = "0.200000">
</light>
                         
                         

Using the Cached Pathlight

Using the Irradiance Cache feature can be tricky, the results are well worth it, as you can usually get the same quality image in a fraction of the render time.

The cache size is the size of a grid that the scene is divided up into. As the rays are shot into the scene, they intersect objects, the point at which the ray intersects the object will therefore fall into one of the boxes formed by the cache grid. At the time the ray hits this point the renderer first asks:

1. "Are there any other sample points within this box?" If the answer is no, a sample is taken, if there are other samples in the box it moves on to the next question:

2. "Are the surface normals of the other samples different to my current point?" (the angle of difference is defined by "angle_threshold"). If the answer is yes, a sample is taken, if the surface normals are all the same it moves on to the next question:

3. "Is the Intersection Point close to any other object?" (the distance threshold is defined by "shadow_threshold" and the distance between the intersection point and the existing sample points plays a part). If the answer is yes, more samples are taken, if no, the sample point is skipped and the renderer moves on to the next intersection point.

By doing this, the renderer finds areas of the image that need more samples (areas of high detail), and areas that need less samples (areas that have low detail, such as flat walls). Taking samples is the time consuming part of Global Illumination, by only taking samples where they are necessary the cached pathlight can produce fantastic images in a comparatively short time.

It does rely on some manual tweaking to find the 'sweet spot' for the settings for any given scene. If the cache size is too small, practically every sample point will be taken anyway, as the answer to question 1 will almost alway be 'no'. On the other hand if the cache size is too big, the distance in between sample points (which plays a part in determining whether another object is considered 'close') will be such that the answer to question 3 will almost always be 'yes'. Both of these situations will result in more samples being taken and the render taking longer.

Hemi Light

This indirect lighting system performs what is commonly called an 'Occlusion pass'. This produces a fast diffuse light in the scene by ignoring objects surface properties (colour) and just determining whether the point in question is in shadow or not. Because of this, the Hemilight will not produce colour bleeding between objects (unlike the pathlight). It uses either a Monte Carlo raytracing algorithm (MC), or a Quasi Monte Carlo raytracing algorithm (QMC). Since MC uses random sampling the results can be quite noisy. The more samples you take the less noise you'll see, of course this results in longer render time. QMC sampling on the other hand produces less noise, but sometimes can result in descernable patterns in the shading of objects. Both noise and patterns can be reduced with yafray built-in Anti Noise Filter.

The Hemilight will assume that the scene is evenly lit, as if a huge sphere surrounded the scene, lighting it with the color you specify in the 'color' tag. If you omit the color tag altogether, the hemilight will sample the render background if available (you can use this with HDRI backgrounds to get fast and realistic lighting simulations for compositing into a real scene).


<light type="hemilight" name="sky" power= "0.500000" samples = "20" use_QMC = "on">
        <color r ="0.800000" g ="0.900000" b ="1.000000" />
</light>
                         
                         

Hemilight with light blue colour value (model from www.amazing3d.com)

Photon light

This is a focused light to produce radiosity and caustics effects.


<light type= "photonlight" name="Lamp.002caus" power = "100.000000" photons = "50000" depth = "3" search = "100" angle = "15.000000"
        mode = "caustic" fixedradius = "0.100000" cluster = "0.010000" use_QMC = "off" >
        <from x="6.372691" y="3.340035" z="2.815973" />
        <to x="0.285646" y="0.149627" z="1.397566" />
        <color r="1.000000" g="1.000000" b="1.000000" />
</light>
                         
                         

Photon lights have two modes, "caustic" and "diffuse". In the first mode the light will draw reflected and transmitted photons, causing light to form caustic patterns of light that travel through transparent objects (ie objects that have the appropriate settings in their Object tag. In "diffuse" mode photons are reflected by diffuse surfaces in random directions to perform "radiosity" or "Global Illumination". In both modes only indirect light is stored (photons which have bounced at least once), so direct lighting still has to be done with a normal light.

Why not to work in both modes? You usually put different photon values for caustics than for radiosity. The needs change so is better to have two different lights for each task.

Tuning Photonlights

photons

Choose a good value depending on the task, for radiosity you'll need few photons. For the caustics it depends on what resolution you want in the shapes.

search, fixed radius and cluster

These settings are closely linked, you need to get the combination of all three settings right to achieve good looking results. The search setting defines how many photons to look for from a point, the fixed radius defines how far from that point to look for the photons. Once the photons have been gathered, the fixed radius area is gridded up into small 'clusters', the size of which is defined by the cluster setting. Any photons within the same cluster are averaged into one result (equivalent to 1 pixel in the photonmap).

If your diffuse or caustic effects look fractured into geometric shapes, the algorithm is not finding the required number of photons (search) within the defined radius (fixed_radius). To fix this you need to make sure there are enough photons within the search radius to reach the search amount. To achieve this, you could either increase the total amount of photons (photons), increase the search radius (fixed_radius), or decrease the amount of photons searched for (search). Increasing the number of photons will slow down the first pass, you will probably have to add a lot more photons to see much change . Increasing the search radius will show results quickly but is also reliant on there being enough photons in the scene initially. large differences between the fixed_radius and cluster settings (eg high fixed radius and low cluster) will greatly increase rendering time (which makes sense, as each sample (which will be large due to the high fixed_radius) is being split into a lot of tiny clusters (because of the small cluster size). A good rule of thumb is:

fixed_radius/cluster = sqrt(search)

This means that if you are trying for 100 photons (search = 100) then fixed_radius divided by cluster should equal 10 (sqrt(100)=10) so if we set a cluster size of .01 then fixed_radius should be around .1 ((10*.01 = .1) = (.1/.01 = 10))