Linear Workflow with YafRay (Tutorial)


#1

[ul]
[li]Well, sometimes you must be thinking what Gamma Correction is used for. This setting, available in both Blender and YafRay, is not something you can play with depending on your scene. This setting is in fact closely related with your monitor gamma. What is Gamma?<<
[/li][/ul]

[ul]
[li] Before starting this tutorial, you should perform a basic calibration in your CRT monitor. It consist on four steps:
[/li][list]
[li]Whitepoint.
[/li][/ul]
[ul]
[li]Contrast.
[/li][/ul]
[ul]
[li]Blackpoint.
[/li][/ul]
[ul]
[li]Gamma.
[/li][/ul]
[/list]

[color=Wheat] [color=Silver]Note: This tutorial doesn’t cover basic CRT monitor calibration. I strongly recommend it, even if you are not interested in linear workflow. These are links about this topic:[/color]
http://www.normankoren.com/makingfineprints1A.html
http://www.hugorodriguez.com/calibracion/calibracion_v2_01.htm[/color]

                      PC/Windows Monitor Gamma in non-calibrated CRT monitors is by default 2.5 (more or less).
           My calibrated CRT monitor gamma is 2.2 ([b]PC/Windows[/b]). I don't like my YafRay renders with linear response ([b]Gamma Correction=1[/b]) but with Gamma correction according to my monitor ([b]2.2[/b]). It is called linear workflow. 
            
            
            The most interesting of linear workflow is the change in light attenuation. Your light seems to reach further and the decay is different. Seems that there is more range for shadows. In fact, in linear workflow you use more dinamic range and in a different way. 
            
            
            You can overcome this situation in default non-linear workflow, I agree on that, by simply using more power, more lights or lighting tricks, but lets see how results differ in a real situation ([b]YafRay/ PCWindows/ CRT Monitor Gamma 2.2/ 6500kº whitepoint[/b]):

[ul]
[li]NO gamma correction/ Point light / Rayshadows/ Radius 0,40/ Power 0,15. Quite dark here. If you don’t have your monitor calibrated you probably won’t see anything.
[/li][/ul]

[ul]
[li]Gamma correction 2.2/ Point light/ Rayshadows/ Radius 0,40/ Power 0,15. Texturing is washed out, but let’s concentrate on lighting. Notice how lighting reach every corner of the bedroom with no problem.
[/li][/ul]

[ul]
[li]Then we try to overcome the dark lighting of the first render with more power. NO gamma correction/ Point light /Rayshadows/ Radius 0,40/ Power 1. Texturing is right, but lighting has dramatically changed from the previous render! Notice how lighting seems to stop suddenly and there are problems of underexposition in the other side of the bed.
[/li][/ul]

[ul]
[li] In fact, if we look at their histograms, they differ completely one each other. Histogram of the third render (right) shows tendency to oversaturation and higger amount of totally black shadows. In fact there is even less contrast but colors helps to solve this situation.
[/li][/ul]

Notice that we can try to simulate a more natural point light decay in a non-linear default workflow by a higher radius (about 2.5), but then render times increases a lot (x3). We can try also more lights to simulate a more natural decay in non-linear default workflow, but at cost of more time for renders. The result is unpredictable and some tweaking may be necessary.

                                  Then imagine that I could turn back in to linear space texturing and colors of the [b]second render[/b]? That would be nice!

[ul]
[li] To change a texture or color into linear space: Inverse of Gamma 2.2=> 1/2.2= 0.455. Open a texture with the Gimp, go to Layer>Color>Levels>Gamma=0,45
[/li][/ul]

[ul]
[li]Bed Texture. Left, gamma corrected. Right, linear space.
[/li][/ul]
[i][color=Silver]
You migth have problems converting a Gamma corrected texture/color which is very close to the dark extrem of the tonal gamma (in short, very dark!) into linear domain.

                                                After a 0,455 gamma compensation (1/G) with The Gimp Levels tool, it migth become so dark (well, almost black) that even Yafray gamma correction can't correct it. 
   
  [[color=Wheat] playmesumch00ns](http://forums.cgsociety.org/member.php?u=7492) made this comment regarding Gamma compesation:
   [/color][/i][/color]"Don't know if this is possible in blender/yafray, but I prefer to do colour space conversions in shader rather than on the raw texture data. Since a gamma correction of 0.45... tends to make most images considerably darker, you end up losing most of the range of an 8-bit texture. Doing the conversion in shader preserves as much range in the data for as long as possible."
   [i][color=Silver]                                        
   Gamma correction in shader is still not implemented so the most of the time we need to test a new color/texture from the linear domain if the conversion doesn't give us a proper result.

[color=Gray] If you have acces to a 16 bits editing software (Photoshop, Cinepaint) you can try to convert 8-bits textures into 16-bits but then you will have to apply filters to fill the added range. But that’s another story…
[/color] [/i][/color]Everything with color in the scene must be converted into linear space: Textures, materials, color of lights, background, etc.

[ul]
[li]Gamma correction 2.2/ Point light/ Rayshadows/ Radius 0,40/ Power 1. Textures and colors in linear space.
[/li][/ul]

[left]Remember that the process have beed done in a PC/Windows environment, with a CRT Monitor Gamma 2.2 calibrated / 6500kº whitepoint. The Yafray Gamma correction used (2.2) is directly related with Monitor Gamma (2.2). In fact, you should have this config. (or Linux/Mac equivalent) to see properly the images of this process.
[/left]

[ul]
[li]Comparative. Left, Gamma Correction 2.2, textures/colors in linear space. Right, no Gamma Correction, textures/colors gamma corrected. Point light /Rayshadows/Radius 0,40/power 1
[/li][/ul]

[ul]
[li] Finally, lets take a peek on their histogram, surprisingly their are quite similar. Maybe not. With Gamma correction (left) the graphic is more irregular, which means more contrast, there is not overexposition at the end of the scale (drop) and there are much more medium tones (hill). With non-linear workflow (right), the graphic is quite flat and it becomes steep in both extrems of the graphic.
[/li][/ul]

[ul]
[li]Related Links:
[/li][list]
[li]http://www.gijsdezwart.nl/tutorials.php
[/li][/ul]
[ul]
[li]http://www.throb.net/site_main/LinearWorkflow.html
[/li][/ul]
[ul]
[li]http://www.happy-digital.com/freebies/tip_gamma.html
[/li][/ul]
[ul]
[li]http://xona.com/colorlist/
[/li][/ul]
[/list]

[ul]
[li]Here you can download the Blend files of this tutorial:
[/li][list]
[li]http://www.zshare.net/download/testgamma-zip.html
[/li][/ul]
[/list]
CONCLUSIONS
Linear workflow is for lighting enthusiasts! If you don’t mind the drawbacks, the advantages are huge in my opinion, your lighting and shadows are richer and your scenes have more realism. Linear workflow have been always there, but Blenderheads have harly used it.

                                    I would like some feedback from experts because I'm not that experienced in these questions. I will keep on editing this tutorial to polish it.

#2

very interesting. i’m going to use this from now on.

on the mac of course the standard gamma is 1.8 instead of 2.2, for any mac users out there.


#3

Wow. I mean, wow.

I finally sat down to do the full calibration of my powerbook’s screen, and it made a world of difference. Now that I’m using the gamma adjustment in my Yafray and internal blender renderer renders, my images are turning out a thousand times better. Cheers for the tip, Samo!

Also, I discovered that unless you do the expert calibration you end up with a calibration that’s not even remotely like what you should be seeing. Mac users: make sure you choose the expert setup when working on your LCD color settings!


#4

Thanks TroutMaskReplica and kattkieru, here you can download the Blend files of this tutorial:

http://www.zshare.net/download/testgamma-zip.html

:slight_smile:


#5

Also, I discovered that unless you do the expert calibration you end up with a calibration that’s not even remotely like what you should be seeing. Mac users: make sure you choose the expert setup when working on your LCD color settings!

i use a colorimeter. in my opinion it’s not really possible to get reasonable results with software profilers, at least in my experience.


#6

Samo - you might consider adding this in the Blender wiki tutorials, and likely parts of it should go in the manual,

LetterRip


#7

Samo - you might consider adding this in the Blender wiki tutorials, and likely parts of it should go in the manual.

Thanks Tom, ASAP! (I’ll send you an e-mail to Gmail)


#8

You might want to try this to calibrating the monitor. Last I checked the ver 1.0 is a freeware and simple starting point.

** Monitor Calibration Wizard
for print
http://www.hex2bit.com/
http://www.hex2bit.com/products/product_mcw.asp


#9

Thanks jagarts!

Well, the blender files have reached the 100 downloads mark. A big thanks is all I can say.

I discovered this technique by chance. I had a link pending to review in an special folder I have in bookmarks for things I stumble across but I don’t have time to read. Later on, reviewing that link, I wondered how it can be applied to Blender/YafRay.

Thanks again. Have a happy linear rendering.

Alvaro.


#10

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.