free rays for you
get it Get it get it Learn YafRay enjoy Enjoy contribute Contribute
Skip to topic | Skip to bottom
Home
UserDoc
UserDoc.GauravGuider1.7 - 02 Jun 2005 - 09:25 - LuisFtopic end

Start of topic | Skip to actions

Yafray as an Integrated External Renderer

Relevant to Blender v2.34

by Gaurav Nawani

References

Gaurav Nawani Site You can download a PDF version of the tutorial there.

Same tutorial on Blenderman.org Blender.org official guide

Part 1

Yafray integration is one of the best features added to Blender. The current release of Blender 2.35 has a very neat integration with Yafray from within Blender, and is fairly stable to use. Unfortunately, Yafray usage is limited to those who are already comfortable with the Blender interface or can hack their way through. The first part of the tutorial deals with the basic steps needed to render from Yafray and later parts serve as a guide for the rest of the Yafray's available features.

Interface

Blender has two of its own rendering engines built-in and that includes it's own raytracer and an older scan-line rendering engine. Yafray however is a standalone raytracer. Its functionality is accessed through Blender's interface by exporting the scene parameters to a Yafray readable format by one of two options. For the first one Blender has the required support built-in which allows Blender to use Yafray as a plug-in, virtually as if Yafray were an inbuilt renderer, and the other option is where Blender exports the scene data to Yafray format in an XML file called YBtest.xml, and then Yafray renders it as a standalone program. Both methods require Yafray to be first installed on the system and it is assumed that you have both Blender 2.34 and Yafray 0.07 installed on your system.

The Yafray integration in Blender can be broadly categorized in two parts. One relates to the interface for light or lamp settings. The other one to the core Yafray rendering features.

Step-1

It is to be noted that this step might not be necessary for Windows. Before we proceed, we first need to configure Yafray preferences. Drag down the top menu bar to un-hide Blender's User Preferences window. Here click on File Paths button to open up the Path preferences menu. On the top left part is the YFexport text entry box. Enter the path where you would like to save the exported blend file in Yafray format (XML file) while rendering with the second option. This is necessary if you want to save the exported file and later edit it manually.

Figure 1
Figure 1. Path selection in User Preferences menu.

Step-2

As you are now aware, Blender allows you to choose between its own internal ray-tracer and Yafray. To use Yafray you first have to instruct Blender. To do that press F10 for Rendering Options window, now go to the Render tab in the Render Options window (Figure 2). In the Render tab, select Yafray from the Render engine drop down list (Figure 3), by default Blender internal is selected.

ALERT! Note: Please do not get confused with the Ray button. This has nothing to do with enabling Yafray's ray-tracing. It does not effect in any way the Yafray renderings if Yafray is chosen as the raytracer from the rendering engine drop down list.

Figure 2
Figure 2. The default options in Render Tab.

Notice as soon as you choose Yafray two more tabs appear beside the Render tab (Figure 3). These two extra tabs are Yafray and Yafray GI and these two tabs have rendering and other features and parameters of Yafray.

Figure 3
Figure 3. Yafray raytracer selection and its two sub-tabs.

Now select the Yafray tab from the two new tabs, there will be some functions visible, right now we are interested in the button named XML (pressed by default) (Figure 4). You go ahead and turn it off right now. I will explain why, as I had told earlier that Blender has two options for rendering with Yafray, either as plug-in interface or to call Yafray as command line program.

Figure 4
Figure 4. Default Yafray tab with Yafray file export enabled. (XML button).

Figure 5
Figure 5. Disabled Yafray export.

Choosing the plug-in or first option (XML button off) allows you to see the rendering progress in the Render window (Figure 6), much like the Blender's own rendering, and this is one of the reasons why Yafray requires and uses more memory than before. Using the second option which is by default (XML button pressed) active, will first export the active scene to the YFexport path, which you have set in your File Paths preferences (the Section called Step-1). The Yafray is then called as a command line program, and it takes over the processing of the exported XML file, and only after completion provides the image back to the Render window, so there is no other interaction in between, save for the textual output in the Blender's terminal window.

Figure 6
Figure 6. The rendering in progress for Yafray XML disabled.

Step-3

After going through the first two steps you have virtually done every thing to make a Yafray render. At this time you have your scene ready with lamps of your choice, the best thing to proceed from here is to press F12 to render. Here is where the problem crops up for almost everyone. I will explain... Depending on the light settings in your scene, you either will see a blank screen or will see very faint outlines of the objects in the scene. Or if your lamps have higher light intensity (value) then you might see the scene properly. Alternatively, in extreme case, Yafray and Blender do a crash thingy.

In case you came up with black render the chances are good that you can render through Yafray, all you need now is to adjust the light's parameters, and you will have your own Yafray render within minutes.

Points to check for problems

  • The first problem for Yafray renders is almost every time a lack of sufficient light intensity in the scene. This is not actually a problem of Yafray, but an implementation issue from within Blender. So, in this case, you need to increase the light intensity, or value, of every lamp in the scene (more information in the Section called Part 2).
  • If every thing fails you might need to check for the distance value of the lamps, since the light attenuation falloff is mostly sharper in CG (to reduce computations), your objects in the scene might appear black because their ray casting distance just might not be reaching the objects in the scene. You can get around this by adjusting distance value in the Lamps tab.
  • In case of crash please check the elysiun forums for possible answers.

Part 2

Instead of instructing you to modify the settings here and there, I thought it might be better to explain the Yafray light types one by one. This will enable you to make informed decisions. Let there be light... And there was Yafray everywhere

There are five light types used in Blender and of them only four are directly supported in Yafray. On enabling Yafray raytracer from the Render tab, you initially see six lamp types (in the lamp options window, F5), of which Yafray makes use of Blender's lamp, area, spot and sun. I will come later to the other two lamps listed, Hemi and Photons later.

Figure 7
Figure 7. The scene.

The scene description: The current scene has two light sources. One is a helper light (Sun, without shadow and at value .200), which is used to provide non-directional light to increase the ambiance for the scene. The other is the lamp source (or light source), which is a placeholder for every light type explained. The lamp positions are static through out, and Ray Shadow (shadow casting) is enabled for all the lamp sources that are being used (see Figure 8).

Figure 8
Figure 8. The scene as seen in the Viewport.

ALERT! Note: The suggested uses for the light types defined here are general in the usability approach. They are not to be taken as the absolute word for lighting your scene. The lighting varies depending on the scene and the artists own vision for the scene. For best results experiment with the lights in your scene to find which works best for you.

TIP Important The mention of render times in the images is rounded off, it is relative and is used just to give the idea of typical render times for same scene by different lights and settings.

Lamp

This is the simplest light source available, in some ways it is like sun, as it is omni-directional (i.e. shoots light in all directions from the point of its origin) and is spherical in nature. Since it shoots light rays in every direction, that means the ray going away from the scene will not make any visible changes in the scene, the light rays will be lost and thus are waste of computation, Although Ray tracers use a variety of hacks by cutting off the unwanted computations, it is a bit slower than other directional light sources if bigger parts of the light shot come inside the scene view.

The general use of Lamp is for indoor lighting, like rooms and halls, but it is not limited to this use, it is also more commonly used as filler light or helper light in the scene.

Values: When a single lamp is used for the scene in Yafray (through-out the tutorial when I say Yafray I mean Blender-Yafray), it will generally not provide sufficient lighting to light up the scene unless it is kept at a higher value. For the sample scene, the value of Lamp was set at 10 (maximum) but still there seems to be the need for additional lighting (but we are sticking to it for the sake of understanding). See Figure 9.

Figure 9
Figure 9. Rendered with Lamp at default settings.

The Lamp will cast sharper shadows at default (zero) radius. The radius setting in Lamp is used to increase the area size for shooting the light. If the size of Lamp is bigger than the objects, then the light shot from some parts of the lamp could directly reach to the parts of the scene where the other part of the lamp casts a shadow. This intersection results in the shadow being diluted for that part, thus getting blurred (also called partial shadows). You can observe this phenomenon in real world (sun light).

LINK: for more info on shadow dilution or Partial shadows go to Ditto head's Light tutorial at blenderman.org.

Figure 10
Figure 10. The noise comes when sampling values are low.

The scene above (Figure 10) was rendered at radius 2 with a sampling value at 1, as can be seen the scene has grainy partial shadows. The use of samples button is only to reduce those grains in shadows, the sampling buttons control the number of samples used in shadow calculations, increasing the sampling results in smoother shadows. The sampling button is only available in lamp and area light and functions the same for both.

Figure 11
Figure 11. The increase in sampling to 5 removed the noise.

Area

The Area Light is a directional source. The shape of Area Light can be varied from square to rectangular from the drop down list in the Lamp tab. Below the shape selection there is also an option to increase the size of the Area Light.

Figure 12
Figure 12. The basic render from area light at default setting and value of 4.

Values: For Area Lamp you will need lower light intensity values for rendering a scene with Yafray. The sample scene is lit by light value at 4, it is brighter than the one rendered by lamp at value 10. This is because it is shooting all the light towards a direction from a plane while the lamp shoots the light in every direction distributing energy where it may not be required.

Figure 13
Figure 13. Although the scene looks similar to Figure 11 in the Section called Lamp but is brighter and have better shadows.

ALERT! Note: One important point to remember is that in the official Build of Blender2.34 using two or more area lights results in error in the renderings, it is a recognized bug and have been patched in some development builds.

Spot

The spot is also a directional light source and as the name suggests it provides a circular spot of light or more appropriately a cone of light. The size of cone can be controlled by the SpotSi or angle of spotlight beam. The higher the angle the more nearer it behaves like an area light, but with one major difference. It cannot cast partial shadows. Spot light has a parameter to control the SpotBi or Spot's edge smoothness only. It can be seen only if the spot light is inside the scene view, otherwise you will not notice any difference in spot or other lights.

Figure 14
Figure 14. The Spot lamp render with default settings.

Figure 15
Figure 15. Spot lamp with spherical light attenuation.

Notice the increased brightness at the portion nearer to the lamp in the Figure 15 while using the Spherical light attenuation (quad is not supported in Yafray). Increase in the distance value the spherical attenuation also increases in radius, for example the Figure 15 has a default distance value of 20 while Figure 16 has the distance value at 30. The effect looks like that of typical household lamps where the attenuation is sharper.

ALERT! Note: The light attenuation in Yafray has only quadratic falloff, while Blender can have linear, cubic and the mix of these also. That explains relatively sharper light intensity falloff in Yafray renders.

Figure 16
Figure 16. Spot lamp with Spherical attenuation enabled.

Sun

This is also a directional light source. It tries to emulate sunlight by shooting light of the same intensity everywhere in the scene without attenuation (Figure 17). This results in the environment being lit up with constant ambiance. Its value must be kept lower. The sample scene uses a light intensity value of .100. It is obviously good for out door lights, especially for a sun.

In outdoor scenes, if you do not want sharper shadows you can disable shadow casting for sun, and use other lamps for shadow generation. But make sure they have sufficient light intensity to cast a shadow.

Figure 17
Figure 17. The sunlight at value 2. No wonder why this lamp is called Sun.

More lamps?

  • Hemi - Yafray does not support Blenders implementation of Hemi light internally; right now it just uses Yafray's implementation of sun light instead, so you can use Sun light instead.

  • Photon - Last of all, the Photon light source or photons lamp button is not to be confused with any light source. It does not cast any shadow or light, it is only used in Caustics calculations and requires being placed or directed where you need the caustic calculation. Photon lamp shoots photons in an area, the photons are used by Yafray as the specialized ray elements only to calculate the caustics on passing through the objects like glass or mirrors, which have have the property of bending light when passed through them, known as total internal reflection. Basically the placement of photon lamp is to allow the user to optimize the rendering. Caustics is one of the most computation intensive jobs in Ray tracing.

ALERT! Note: This photon lamp and photons are not to be confused with the photon option in the GI method. Which is explained in the the Section called Part 3.

Part 3

GI and other features

Yafray supports Global Illumination. We have to go back to the Render tab to learn more about Yafray's implementation of GI. The first look at the Yafray GI tab and you might think. Oh! It is so easy, you are right the features available are simplified for your use. The available options are Method and Quality, lets have a look at them one by one. The quality is the same for both and is explained later.

Figure 18
Figure 18. The Yafray GI tab.

The available Methods of GI

Skydome

While Skydome is simply a method to have lighting from the sky or more appropriately the atmosphere, it does not provides full GI in the true sense, as it does not takes into account the indirect light bounces on the surfaces of objects. Rather it affects the light in the scene by the colour of the atmosphere and also the diffusion of light in the atmosphere is controlled by it. For example in the default scene the colour of atmosphere was set at reddish (chosen just to clearly identify the affect). See Figure 19 for how the diffusion effects the scene.

Figure 19
Figure 19. The left part of image have the power of diffusion set at 2 while the right one at 4.

The colour of the background or atmosphere can be changed in the Word Panel (F8). You have to enable the world for Skydome to work fully. The Skydome offers no other features. The Skydome is faster method of GI, while its results may not be physically more accurate, its results are not too bad to ignore for the speed advantage it offers.

Full

On the other hand, the Full option takes into consideration the reflected and/or refracted light bounces (or indirect light) on neighboring surfaces. This method is a very close simulation of actual lighting in the real world, and that is why the GI produces more photo-realistic images than any other method used in CG, that is also why it requires higher computations and is slower.

Figure 20
Figure 20. Using Full GI increases the time as well as realism.

Notice the difference in realism between the two parts in Figure 20.The light bounces provide enough diffusion in the second part of the image, which lights up the shadow portion in the scene according to the distance of the surfaces in contact. While the first part has approximately similar shadow depth through out.

Figure 21
Figure 21. The Yafray GI tab. Options for full method are visible

Features for Full method of GI

Depth:

This refers to the total number of light bounces for one reflected or diffuse ray. Generally the depth 3 works best for normal scenes. Increasing the depth results in higher amounts of calculation per ray.

Cdepth:

The Cdepth is nothing but the bounce depth for caustics, or for the transparent materials like the glass, gems, liquids etc. Higher computations are required for caustics calculations, that is why the GI in CG keeps separate the normal lights with photons, even though in the real world the photons are the actual light particles. For better quality of caustics you will need to have as much as 3-5 Cdepth or more for detail.

Photon:

This photon button should not be confused with the photon lamp. This is only used as a helper in global illumination for Yafray and bears no relation with the caustic photon lamps or caustic photons.

Count:

The count refers to the total number of photons to be made available in the scene for helper in GI. The number of photons will will vary for the scene, but higher numbers in the scene will provide smoother results, again its at your disposal to find time/quality limit.

Radius:

This refers to the distance within which the photons calculated have higher precision value to effect the GI, outside which the photons do not effect the scene much. So the Idea is to optimize the radius to the size of the area where better GI calculation is required. Keep the radius half the size of area.

MixCount:

This allows you to choose the number of photons which should be kept inside the Radius. The Radius and Mix Count make up your photon map. The photon-map is nothing but the optimized area for photons used in GI calculation and Yafray sufficiently processes the sampling and photon gathering on the photons inside the photon-map and leaves the photons outside the photon-map.

Tune Photons:

This allows the re-use of successful gathering of photons and positions from cache, which helped in GI calculation on previous render, and only re-compute the other photons for faster result. It is may not necessarily faster in every rendering but can provide good speed improvements generally. Due to speed improvement it is good to use it during test renders once you come close to what you wanted. You can disable it after you are satisfied with the test renders and want to create the final version of the image to do the full computation again.

Quality:

The quality dropdown list allows you to choose the quality level of GI for both the Skydome and Full GI methods. Quality setting allows control over the number of samples used to sample in GI. Since its use is automatic by default, it will try to used maximum value for MultiPasses and samples per pass depending upon the quality level. If you want, you can disable the AutomaticAA manually and can instruct Yafray accordingly.

Other features of Yafray

Anti-Aliasing:

The YafRay tab in Rendering options window lists the options for manual control over anti-aliasing. Press the AutoAA button to un-hide the manual settings.

Figure 22
Figure 22. The Yafray tab.

  • AAPasses: It is used for the number of passes to be used for Anti-Aliasing. The higher the passes, the better the results, longer render times also. While using passes of more than one, every pass samples the total number of samples chosen in AASamples for every pass, thereby achieving better AA of pixels in noisier areas. If the results are noisier in a single pass you can increase the number of passes for better control and also a higher number of samples per pass. Single pass anti-aliasing with higher sampling, is not necessarily better than lesser samples with multipass.

  • AA Samples: The number of samples per pass. The total AA sampling can be calculated by multiplying AApasses with AAsamples. In our case for the the final blurred image for the DoF used below, we have used 4x4=16 anti-aliasing samples.

  • Psz: The psz is the >Pixel filter size>, that is used during the Aliasing calculations for aliasing the overlapping of neighbouring pixels.

  • Threshold: This sets the threshold or the maximum brightness difference with the neighbouring pixel, when this is above the chosen level, extra samples are taken until the result is below the threshold limit or maximum samples/passes are reached. Lower threshold means more pixels will be antialiased, so at 0 all pixels in the render will be anti-aliased, when 1 no anti-aliasing is done.

  • Raydepth: This effects the maximum number of bounces a reflected/refracted ray can make. This is only important for glass and mirrors, higher ray depth will improve the quality of the reflection/refraction in the glasses and or mirror.

The Depth of Field

Yafray supports the real camera like DoF. The DoF of filer setting can be accessed easily. First select camera in view port then press F9. You will see a tab along with the Camera tab named Yafray DoF. In the Camera tab enable Show limits, doing this will allow you to see a yellow cross on the Show limits line of the camera in Viewport. The yellow cross is what we need to put at or near the objects we want to have sharp focus on. That distance can be set by the DoFDist numeric button. The Aperture setting is the value you need to change to get the required DoF you want. Normally a setting in between .100 to .500 will suffice for most scenes.

Figure 23
Figure 23. Notice the noise on the wooden boards.

How to remove the artifacts in DoF rendered scenes. DoF filter requires more samplings per scene to get the right amount of blurring. To do that you need to disable Automatic AA in Yafray tab in Render panel. Here try to adjust the AAPasses and AA Sample accordingly. If you have large aperture settings then you need to have multiple passes plus higher samplings per pass. Increasing anti-aliasing will also increase the render times.

Figure 24
Figure 24. Increasing the sampling manually, and aperture size solves the problem.

HDRI or High Dynamic Range Illumination

Yafray has HDRI support. To use this go to World buttons F8. Go to Texture and Input tab and add a new texture. Then go to texture selection F6 select Texture type as image, press Load image button, locate the HDR file, select and press Enter. Blender will not show the HDRI image in the World tab, however it is loaded automatically during rendering. You can also increase or reduce the exposure of the HDRI from the Texture brighteners button in the colour tab in texture window (F6). The possible exposure settings are -1,0,1, for brightness' sliders at 0,1,2. This is because HDRI exposure can be modified in integer values only. For the final step, use any one of the GI methods. Generally Skydome will work fine.

Figure 25
Figure 25. HDRI render using Uffizi probe. It need more quality level.

Closing comments

I would like to thank eeshlo, to an large extent I was motivated to learn about Yafray because of him, and thus was able to write this tutorial, and also for his help in solving my queries. Thanks also goes to Dreamsgate for helping in the editing and support for this document.

This tutorial is not finished, as there are several aspects which I have not tried myself, like caustics, and GI techniques for certain types of renderings. So I call this tutorial version 1. Later improvements will not necessarily come at regular intervals. If you have any queries or have some point that I overlooked or misunderstood in the matter written above. I would be glad to hear from you. Also welcome are the suggestions for improvements. E-mail: nawani_g AT yahoo.co.in

Glossary for the geeks

Global Illumination.

It is a method (algorithm) of computation for light calculation in the scene which, takes in to account the light bounces from the neighboring surfaces, along with the normal illumination of direct lights. In Other words GI calculates the Indirect light also, thus it makes the renders more photo-realistic. Examples of GI methods are Radiosity and Ambient Occlusion in Blender and on a general scale Radiosity, Ray tracing and Caustics all use different GI algorithms.

Ray tracing.

A method in CG which uses an algorithm to calculate the effect of lights on the surface of objects in the scene. In CG the ray-tracer. works by calculating the light effect on the scene by tracing the light photons back to the point of origin, from the scene or the camera. It uses the reverse of what is in real life, the sun shoots photons and we receive them through reflection/refraction from the objects, the photon energy is also modified by the objects by absorption or adsorption to form a particular texture or colour of the object.

The reverse way of ray-tracing is done so as to reduce the amount of calculations, as it is faster to take just the photons or lights which reach the scene or our eye or the camera, than calculating everything what is outside the view.

Photon.

The photon is also referred as Ray of light. And it is the smallest unit of light energy.

Caustics.

The caustics are referred to as the refraction pattern formed by highly transparent objects such as a glass of fluids which have a certain degree of Total internal reflection, for example the light falling on a glass filled with wine will form some strange patterns of different colours and intensity which are referred to as light caustic. The computer method for Caustic calculation is also referred to as photon mapping. The photon lamp in Blender/Yafray is for this purpose only.

HDRI.

Or High Dynamic Range Illumination. This method is relatively new in GI. This uses the actual light probe value of a real scene in the real world taken through with special equipment to produce a 360 view of a scene, and stores the information of the light from all areas in the scene in a spherically mapped image called HDR. The renderer uses that information to shoot light from and provides even more photo-realistic rendering.

Anti aliasing.

It is refers to a method to reduce the brightness levels between two neighboring pixels by overlapping the colours in the difference level to neighboring pixels. This make the images appear smoother.

Photonmap.

An assumed area or bound with-in which more density of photons are kept for calculations of indirect illumination.


Return to Tutorials HomePage
to top

I Attachment sort Action Size Date Who Comment
figure1.png manage 50.6 K 14 Jan 2005 - 21:51 LuisF Figure 1
figure2.png manage 81.2 K 14 Jan 2005 - 21:51 LuisF Figure 2
figure3.png manage 84.2 K 14 Jan 2005 - 21:51 LuisF Figure 3
figure4.png manage 38.7 K 14 Jan 2005 - 21:52 LuisF Figure 4
figure5.png manage 39.1 K 14 Jan 2005 - 21:53 LuisF Figure 5
figure6.png manage 198.8 K 14 Jan 2005 - 21:53 LuisF Figure 6
figure7.png manage 482.0 K 14 Jan 2005 - 22:17 LuisF Figure 7
figure8.png manage 160.4 K 14 Jan 2005 - 22:18 LuisF Figure 8
figure9.png manage 369.2 K 14 Jan 2005 - 22:19 LuisF Figure 9
figure10.png manage 406.9 K 14 Jan 2005 - 23:17 LuisF Figure 10
figure11.png manage 369.7 K 14 Jan 2005 - 23:17 LuisF Figure 11
figure12.png manage 426.5 K 14 Jan 2005 - 23:17 LuisF Figure 12
figure13.png manage 427.5 K 14 Jan 2005 - 23:18 LuisF Figure 13
figure14.png manage 352.2 K 14 Jan 2005 - 23:18 LuisF Figure 14
figure15.png manage 434.2 K 14 Jan 2005 - 23:18 LuisF Figure 15
figure16.png manage 563.7 K 14 Jan 2005 - 23:18 LuisF Figure 16
figure17.png manage 641.5 K 14 Jan 2005 - 23:18 LuisF Figure 17
figure18.png manage 19.5 K 14 Jan 2005 - 23:18 LuisF Figure 18
figure19.png manage 713.4 K 14 Jan 2005 - 23:19 LuisF Figure 19
figure20.png manage 573.5 K 14 Jan 2005 - 23:20 LuisF Figure 20
figure21.png manage 87.3 K 14 Jan 2005 - 23:20 LuisF Figure 21
figure22.png manage 58.3 K 14 Jan 2005 - 23:20 LuisF Figure 22
figure23.png manage 464.0 K 14 Jan 2005 - 23:20 LuisF Figure 23
figure24.png manage 444.2 K 14 Jan 2005 - 23:20 LuisF Figure 24
figure25.png manage 725.7 K 14 Jan 2005 - 23:21 LuisF Figure 25

You are here: UserDoc > YafRayTutorials > GauravGuide

to top

Copyright © 1999-2009 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback