Tone and Gamma Corrections

Iam still learning... I wasnt aware of the differences between Curve Tool and RGB Curve Node. You opend my eyes.

Thank you.

The wrench changes the curve from bezier to vector handle, so you can make sharp changes in the curve.

You don’t have to render the texture. Just add an “image” node from the “Input” category and then load the texture file into that node.

So far, I am doing this all by eye, trying to match the gamma corrected textures packed in the blend ypoissant posted. Although I’ve come close, they are not exact matches by any means.

That is because I did not do a simple gamma correction. FIrst I applied a reverse gamma correction to get the photo back into a linear color space and then I roughly increased increased the values by 2 for the dark texture. For the light texture, this is a little more tricky.

Anyway, in order to do that sort of thing with Blender nodes, it would help if we had an histogram node. This would guide setting the values in the nodes. If you don’t use PS, then you could do the same operations in The Gimp. It is free and can do that sort of operations quite well.

But now you will see why it would be much more convenient to be able to do that in Blender before the material nodeuses the image and not having to save the image files.

When I made the correction to the light wood, the RGB curve matched the CRT gamma curve, which makes sense to me as a reversal of the gamma correction,

You would be better off using the “gamma” node from the “color” category for that. Select gamma 2.2 for the reverse correction.

but that didn’t seem to work for the dark wood, which came out almost black, so I made the curve shallower and played with the saturation to try to match the sample.

It is normal that this texture comes out almost black. If you work in PS or The Gimp, you can set your workspace to reverse correct the gamma correction and still see the textures as light as you like. My tutorial explains how to do that. In Blender, you just need to add a preview node with a previous gamma node and you will see the texture in a more natural way.

The interesting aspect of doing that in Blender is that once you’ve setup a noodle soup to do the work, then you can reuse it very easily.

A last important note concerning that sort of operation on texture files. Image files should be saved in an image format that support at least 16 bits color depth. Otherwise, a lot of the color information will be lost. And just as important, the operation should be done in 16 bits mode too. That means that the work mode should be changed to 16-bits just after loading the image in PS and before starting to do color corrections. Also, I like to use Adjustment Layers instead of performing the operation directly on the image data. Adjustment layers are like nodes in Blender, they are non destructive of the origial data. Because this was for a simple demonstration, I did not bother with that issue here and I saved to a normal 8-bit file.

The RGB curve node is really just an arbitrary function editor. It gets some input values and transform them according to the function that is implemented by the curve.
This is the core of my misunderstanding. When I read RGB Curve I thought, it would work like in PS, with the same limited color range, but how you said, it`s only a value changer for whatever input.

@ Yves: There’s a histogram display in the VSE. You can import Scene, which is output from compositor, and look at the Histogram in the VSE.

@Toni, you can configure the RGB to only operate on a certain range by using the Map Value node to function as a band-pass filter, and only pass certain values to the node, You would then recombine them by using the original value output as a mask.

One thing to add on. You write:

Today, even though such correction circuitry would cost nothing to produce, there are still no gamma correction in the CRT drivers because every CRT needs to stay backward compatible with all the video equipments that are already in circulation and in use.
But this is only half the truth.

However, through an interesting coincidence, the human eye’s subjective perception of brightness is related to the physical stimulation of light intensity in a manner that is very much like the power function used for gamma correction. http://www.w3.org/TR/PNG-GammaAppendix.html
We not only need this gamma correction for backwords compability, but also because our perception needs it. This is more and more the main reason, why gamma correction is used and will be used in the future, beside the other “gamma values” like camera gamma, encoding, decoding gamma etc. Even if it were possible to create linear camera chips and LCDs`, we still would need a gamma of 2.2.

After some more experimenting, I managed to duplicate fairly closely the photoshop tone corrections in Blender. (I know I could have used Gimp, I’m just being stubborn.) It would be nice if a set up like this could be pipelined in from the same blend file rather than having to render the image separately and load it in as a texture image.


Material nodes for the light wood.
This screenshot also shows the material buttons set up. It’s mostly default, but the Nodes button is selected on Links and Pipeline, Spec is reduced to 0.200 (probably doesn’t matter, since the lamp is set to No specularity) and TexFace is selected on the Material panel.


Combined with composite nodes produce the tone corrected texture image
This screenshot also shows the camera and light set up. The camera is set orthogonal, and the image size is 600x800 to more closely match the original texture image (to avoid stretching.)


The RGB curve was slightly different for the dark wood material.


And the HSV node was set back to default values. The gamma node is not set to 2.2, as recommended, because it doesn’t recognize values above 2.0. The 1.4 value, in both cases, provided the closest match to ypoissant’s tone corrected samples.


@orinoco:

You know that you don’t have to build a render setup to correct your maps? You just need to load the map file into an “Image” node and do the correction on that.

@Toni:

Camera chips (CCD and CMOS) are linear in nature. And we would not want them otherwise. We want image sensor to report as closely as possible the true light in an environment. Correction can be applied after the capture and this is exactly what the digital cameras do. And because camera sensors are linear, working with RAW mode to get textures for CG should be the prefered method instead of reverse correcting the correction that was done by the camera on data that was linear to start with. All those steps degrade the data.

Yes. Our perception needs the gamma correction. And that is why it is added at some point in the pipeline. It is added by the still and video cameras. But for Computer Graphics, a very small number of people worry about that. And this situation is only because the default CRT expect the correction to be applied at the source. If the gamma correction ad been embedded in all TVs and CRTs from the beginning, then we would not be in this situation today and we would not need to discuss this whole gamma correction mess.

I hear ya, but I can’t find that "image: node. Is it new? I’m looking in Material Nodes. I can load an image in the compositor nodes, but then how do I get the composited texture to use in a material?

A screen shot would be very helpful. I’m totally confused. :spin:

I’m using v2.45 so I don’t think the Image node is new. There is a screen shot in one of my previous post here. Follow this link: http://blenderartists.org/forum/showpost.php?p=1070403&postcount=39

To save the corrected image, I select “IM: Viewer node” in the “UV/Image Editor” window. Then once it is displayed there, I select “Save As” in the “Image” menu of the “UV/Image Editor” window.

most interesting, will subscribe to the thread. :slight_smile:

You’ve got the right idea, but your setup is incorrect.

The idea of the gamma correction is to gamma correct the texture before it gets fed into the renderer. That’s because you’ve made the texture to look good in PS/gimp at gamma 2.2, but for realistic lighting, the renderer needs it to be at gamma 1.0.

In your setup, you’re doing the inverse correction too late - you’re actually doing it to the entire render, not just the texture. It’s the material node that does all the shading and rendering, if you add the curve after the material node, it’s just modifying what’s already been shaded - this means you’re affecting the lighting as well, which is not what you want, you need to do that correction on the texture before it gets shaded.

In this attachment, I’m just feeding in a texture to the material colour.

  • The top line is what happens normally in Blender
  • The second line is inverse gamma correcting the texture before it gets shaded (which is what your setup should be doing) but without correcting it back at the end of the render
  • The third line is what happens when you both inverse correct the texture, and correct it again at the end of the render. Usually you’d put that second curve in the comp setup, but putting it here after the material node has shaded it is pretty much the same thing, and shows the result nicely by comparison :slight_smile: You can see it looks much nicer than the one on the top line.

When I get some time I’d like to investigate coding an option in the texture buttons to automatically inverse gamma correct textures before they’re rendered, so you don’t need to do any of this crazy stuff, but that may take a little while. Maybe ypoissant could do it too :wink:

Hope this clears things up a bit!

Attachments


So this is how we should do that! I now wish we had a Gamma node for materials.

When I get some time I’d like to investigate coding an option in the texture buttons to automatically inverse gamma correct textures before they’re rendered
We will wait patiently and pray to the gods :yes:

By the way. Vertex Paint Panel allready has a gamma slider (signs and wonders happens), Texture Paint not, nor the colorpicker… :wink:

I have read through the gamma correction article and this thread but don’t exactly get how to do the actual process. In this case, there is a bathroom scene I am working on that uses all internal textures. Do I need to gamma-correct the textures and the scene or just the general scene as a whole? Some explanation for my personal situation would be very appreciated.

Attachments


Gamma correct the textures first (actually, inverse gamma correct them, since they already have a gamma correction factor applied.) Then light and render the scene, and apply a gamma correction to the finished product.

Hey Broken,

I have a question regarding the way you do your inverse correction in Blender.

You use curves for it - the point you select to bend the curve, is it arbitrary?
I asked because in your image the curves are not the same.

I guess I ask because I am little puzzled that you use curves for gamma.

Yeah it’s kinda arbitrary in that example, but its pretty similar. You can see what the gamma curve looks like here: http://en.wikipedia.org/wiki/Gamma_correction - it’s just brightening or darkening the mid-tones. I don’t actually use this method at all in production and what I did there isn’t exactly the gamma curve, but is probably enough to give a decent illustration of the effect :slight_smile:

Howdy.

I did some experimenting with gamma correction myself. Here’s one tweak:

http://www.loadusfx.net/blender/chess_set_cineon.jpg

Here’s the node editor view:

http://www.loadusfx.net/blender/chessnodes.jpg

I tweaked the lights a bit, added a sun and a sky, ambient occlusion and shadows. Here’s the blenderfile if you want to look at it (apologies to Orinoco for messing with your set ^^):

http://www.loadusfx.net/blender/chess_set_cineon.zip

ypoissant

http://www.ypoart.com/tutorials/tone/texture_environment.php

Adobe RGB is internal Gamma 2.2 - so you could also calibrate your display to Gamma 2.2.

Wouldn’t this make more sense? A display with gamma 1.0 is in-deed very bright.

I know that with the gamma change drastic changes to the image can be applied which is why
you do not want to convert too much in this case here.

I was actually not able to find in Photoshop were you can define a working color space with RGB Gamma 1.0.
Does such a color space profile even come with PS?

As a note the HueyPro is not a bad hobbiest tool - however the ambient function is not really that useful or accurate because it changed the curves of the profile instead of like with my Cinema display changing the background light intensity to match it.

I looked into Gimp 2.6 but the Display menu does not have any Gamma option left.
Any idea where this went to? I googled it but did not find anything useful.