View Full Version : Severe Linear Lighting Confusion

06 June 2010, 07:18 PM
I am seriously confused about what is going on here. Let me lay out my basic understanding, and anyone who sees the errors/confusion in my logic please step in and correct them.

Ok. First off, I made a test image in Photoshop. It is using the generic sRGB color profile (like pretty much all digital images) and so has a built-in 2.2 gamma:

Now, for the simplest possible test of the whole gamma correction thing I just assigned it to a surface shader and did a test render with no gamma adjustment of any sort:

Looks pretty much exactly the same. So then I went ahead and attached a mia_exposure_photographic lens shader to my camera. With the gamma on the lens shader at 2.2 I did another render:

It is washed out - as expected. As I understand it, this is because the image's built in gamma is being further exaggerated by the gamma adjustment of the lens shader. So one approach is to attach a gamma adjustment node to the image file. I give it an adjustment value of 0.455 to de-gamma the original image:

This brings it back to normal again - as expected. The alternate method (which I learned from the famous Floze lighting tutorials) is to adjust the framebuffer gamma. But before I do that, as a quick test, I try turning the gamma setting in the lens shader back to 1.0. Now the image is being de-gammed (not a word) down to .455, but the lens shader is not re-adjusting it back to normal, which I believe means I should get a darker image (the opposite of my first washed out image):

This is, indeed, the case. So now I am ready to try the framebuffer method. As I understand it, setting the mental ray framebuffer gamma (in the render settings) to .455 will apply a global de-gamma effect to all images (unclear if it should apply to color swatches as well). As I understand it, I can use this approach instead of having to attach a gamma correction node to all of my image file nodes. Therefore, I should be able to remove my gamma adjustment node from my image, instead set the framebuffer gamma to .455, and set the lens shader gamma to 2.2 and I should get my original image when I render:

The image is washed out - NOT what I expected. It is like the framebuffer gamma adjustment is not de-gammaing (not a word) my image file. To get a better sense of what is going on I left the framebuffer gamma at .455, but removed the lens shader. Now I would expect to get a dark image like I did earlier:

Again - I am wrong. The render looks like my original default test. Therefore the gamma adjustment that I am expecting to occur is not happening. Am I missing something? Why is this not performing as I would expect it to?

So then I went back and re-read the Floze tutorials:

"As you can see from Fig. 8, we set the Gamma value in the Render Globals’ primary framebuffer menu to the desired value, which is - simply because mental ray works this way - 1 divided by the value (2.2 for approximating sRGB in our case), which equals 0.455."

So he uses the framebuffer to de-gamma his images, which is what I expected. Now I would assume that he would want to keep his lens shader's gamma at 2.2 during all his test rendering (otherwise all his textures would be coming out rather dark, right?). Then, when it is time for his final render (to 32bit), he would simply set his lens shader gamma back to 1 to create a nice linear exr that he can then adjust in post. But this isn't what happens:

"At the same time, we also need to remove the gamma correction of our lens shader, so we must set its Gamma attribute to 1.0 (linear equals no correction; you can select these shaders from the hypershade’s Utilities tab)."

Linear equals no correction - which is the same as a DEFAULT render, right?? I thought the whole point of a linear workflow was to use that 2.2 gamma correction in the lens shader so that you weren't adding tons of lights (or physically inaccurate lights) in order to brighten up the image???

My understanding was that the 2.2 gamma in the lens shader gave you that brightening boost that corrected for the fact that Maya does not work in a 2.2 color space. The point was to use it so that you could get more pleasing images out Maya when using phsyically accurate falloff and whatnot. I thought the de-gamma adjustment of your image files is to compensate for the overall gamma adjustment of the final image (to avoid blown out textures).

But my understanding is turned upside down because Floze does NOT use that method. He adjusts the lighting in his test renders without the 2.2 gamma being applied by the lens.

Then, to further confuse the issue, my framebuffer gamma adjustment doesn't even seem to work like I would expect it to...

If anyone can iron me out on this, I would be eternally grateful. I have been making a supreme effort to get on board with the linear lighting workflow but I seem to be confounded by contradictory information and confusing results...

*edited to fix wacky font problems (what the heck is the default font/size?)

06 June 2010, 08:49 PM
You should check out :

There are quite a few threads that go over this also.

But heres my understanding of a LWF with maya and nuke in a nutshell(if I'm wrong please correct me)

When lighting in maya render with the lens shader with the 2.2 gamma. Keep in mind the lens shader is doing more then adjusting gamma.(a little tonemapping)

De-gamma any file texture that you bring into maya (excluding bump,spec, displace files)

When ready to render you final image take off lens shader and render out floating point.
In your compositing package (I use nuke) import renders as linear but with in nuke view them as sRGB.

06 June 2010, 07:39 AM
Well in my humble experience, setting the frambuffer gamma to 0,45 is the same thing as using a lens-shader with gamma 2,2, but with the benefit that your bitmaps don't need to be piped thru gamma-nodes. With that said, what you're experiencing when using a frambuffer of ,45 with a 2,2 lens-shader is double-gamma.

06 June 2010, 03:28 PM
Thanks for the help guys.

I figured out the answer. Well, sort of...

The simple answer is that there is an inconsistency amongst the various tools for adjusting gamma settings. In the gamma adjust nodes and the lens shader gamma, a value of 2.2 will BRIGHTEN an image. However, the framebuffer gamma in the render settings is inverted, so a value of 2.2 will DARKEN the image.

BUT, and this is important, the framebuffer gamma adjustment will ALSO de-gamma all non-linear (8-bit) images that you are using in your render. It is like the "super adjustment" tool. It both fixes your images AND applies a nice 2.2 gamma to your finished render.

This is why Floze uses the framebuffer value of .455 (the inverted result of 2.2) and disables the lens shader gamma.

The other issue - why was the framebuffer adjustment not affecting my test render of my image? No idea. The framebuffer adjustment DOES work (it just wasn't working on my test image for some unfathomable reason). It is, from a fair amount of research, the PREFERRED method for handling the gamma adjustment (because it ignores linear image files and also because of the affect it has on pixel sampling).

So... yea. All is cool in linear lighting world.

CGTalk Moderation
06 June 2010, 03:28 PM
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.