Gracias Gracias:  0
Resultados 1 al 1 de 1

Tema: GI and HDR lighting in Yafray

  1. #1
    Administrador y fundador. Avatar de 3dpoder
    Fecha de ingreso
    Apr 2002

    GI and HDR lighting in Yafray

    GI and HDR lighting in Yafray
    by Zsolt Stefan


    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 sabes time (and time=money...). It básically 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 algorithm is alos 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 because of time, but because light/darque 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 visualization.

    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, software 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 and HDR lighting in Yafray-fig1.jpg

    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/darque 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 alos load a HDR light probe, which determines what coloured light comes from which direction.

    Product Visualization I - "White Space"

    GI and HDR lighting in Yafray-final_render.jpg

    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 favorite setups, for lak 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, it 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 software shadows are the result of GI.

    The scene

    GI and HDR lighting in Yafray-scene.jpg

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

    The ground.

    GI and HDR lighting in Yafray-ground_settings.jpg

    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 worque 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

    GI and HDR lighting in Yafray-light_settings.jpg

    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

    GI and HDR lighting in Yafray-world_settings.jpg

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

    Render settings

    GI and HDR lighting in Yafray-render_settings.jpg

    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 trik 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 worque 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. Clik 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 trade off. And see how much quality we have achieved with a very simple setup!

    Product Visualization II - HDR Lighting

    GI and HDR lighting in Yafray-hdrsample.jpg

    Instead of a plain white-ish world colour, you can set a High Dynamic Range light probé 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 probé 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 probé 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*512, to 12-15 for higher resolution maps, like 1512*1512. Resave it with a different name.

    Loading the HDR probe

    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.

    GI and HDR lighting in Yafray-world_settings2.jpg

    Scene setup

    GI and HDR lighting in Yafray-scene_setup2.jpg

    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 blok 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 unnaturally 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 software 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, weaque 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 quik 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 probé made with Terragen. This same quality without GI would need a few dozen lamps, all set up properly, so we clearly see the advantages.

    GI and HDR lighting in Yafray-final_render2.jpg

    Not only do HDR maps provide the base lighting of a scene, but they alos provide a realistic environment the objects can reflect. They can alos be the background, however most HDR probes are too low-res to provide a nice background image. Instead, it is preferable 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.

    GI and HDR lighting in Yafray-final_render3.jpg

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

    by Zsolt Stefan

    GI and HDR lighting in Yafray-zsolt_stefan.png I live in Hungary, and am currently studying industrial design engineering at the Budapest University of Technology and Economics. Some of my hobbies are: 3D graphics of course , concept design/product design, plus watching good movies, going out with friends, hanging out on elysiun and other forums, drawing.
    Miniaturas adjuntadas Miniaturas adjuntadas GI and HDR lighting in Yafray-fig1.jpg   GI and HDR lighting in Yafray-final_render.jpg   GI and HDR lighting in Yafray-scene.jpg   GI and HDR lighting in Yafray-ground_settings.jpg  

    GI and HDR lighting in Yafray-light_settings.jpg   GI and HDR lighting in Yafray-world_settings.jpg   GI and HDR lighting in Yafray-render_settings.jpg   GI and HDR lighting in Yafray-hdrsample.jpg  

    GI and HDR lighting in Yafray-world_settings2.jpg   GI and HDR lighting in Yafray-scene_setup2.jpg   GI and HDR lighting in Yafray-final_render2.jpg   GI and HDR lighting in Yafray-final_render3.jpg  

    Imágenes adjuntadas Imágenes adjuntadas GI and HDR lighting in Yafray-zsolt_stefan.png 
    Si vas a subir un trabajo al foro, hazlo adjuntando la imagen, archivo, vídeo o lo que sea, no publicando enlaces de otros sitios.

    |Agradecer cuando alguien te ayuda es de ser agradecido|

Temas similares

  1. Lighting V-ray
    Por alvaro60 en el foro Trabajos Finalizados
    Respuestas: 6
    Último mensaje: 24-10-2012, 19:23
  2. Blender Lighting the Vault
    Por Freemind en el foro Blender Art Magazine nº27 (in English)
    Respuestas: 0
    Último mensaje: 06-06-2012, 18:45
  3. Blender Indirect lighting
    Por Freemind en el foro Blender
    Respuestas: 0
    Último mensaje: 09-05-2012, 17:07
  4. Blender Yafray Interior lighting
    Por 3dpoder en el foro Yafaray
    Respuestas: 0
    Último mensaje: 15-10-2009, 10:52
  5. Lighting the torch
    Por CristianB en el foro Trabajos en Proceso
    Respuestas: 15
    Último mensaje: 05-03-2009, 01:43

Actualmente estos son sus permisos de publicación en el foro.

  • -No puedes crear nuevos temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes responder temas al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes subir archivos adjuntos al no estar registrado o no haber iniciado sesión en el foro.
  • -No puedes editar tus mensajes al no estar registrado o no haber iniciado sesión en el foro.