New Gamma Correction Tool!

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2010   #1
New Gamma Correction Tool! - now with Vray Support

***** ATTENTION *****

I just moved this script to Creative Crash because it's easier to manage and keep track of there.

Here is the link to the script on Creative Crash:

http://www.creativecrash.com/maya/d.../jjj_gammatools


NEW - v2.0 features Vray support!


********************************

I just finished up the first part of a set of tools I'm writing to help myself automate some annoying tasks in Maya related to Linear Workflows and such. The first of these tools is a gamma correction tool. I thought I'd share it here since I often see others asking for such a tool. There are some other nice gamma correction tools out there, but this one does some neat things that I like. Following are a list of the key features that make this one kind of nifty:

************************************************** *******************
KEY FEATURES:

1) Ability to choose either gammaCorrect OR mipGammaGain node.

2) Supports automated gamma correction of COLOR SWATCHES in ONE CLICK!!

3) Allows you to choose a mode of operation:

For instance, if you ONLY want to gamma correct inputs that have file textures
attached but NOT any of your color swatches, you can do that!
OR...if you only want to gamma correct inputs that are color swatches but leave
your file textures untouched, you can do that too!
OR...if you want to gamma correct BOTH color swatches AND file texutres at the
exact same time...you can do that as well!!

4) Fully supports the following mental ray shaders:
1) mia_material (all versions)
2) car_paint_phen (all versions)
3) mi_metallic_paint (all versions)
4) miss_fast_skin_shader (all versions)

5) Special 'Direct Select' mode for handling special case scenarios. (described below)

6) Allows you to undo gamma correction operations and restores
all connections and color swatches back to normal!

7) Automatically turns off 'screen composite' on your miss_fast_skin_shaders when you
gamma correct them (one less annoying button to remember to click...I like that)!

8) Gamma corrects the translucency color of the mia_material IF that attribute is turned on!

************************************************** ********************

Eventually I'm sure the guys at Autodesk will have this linear workflow issue nailed down in 2011 and there will be no need for such tools. But for now I still use 2008 and do things old school. Just in case anyone else out there still likes to do things old-school I thought I'd try and help out and share.

I'm still developing this set of tools so if anyone has suggestions on the UI or functionality I'm all ears. I'll try and incorporate any suggestions if it makes things easier. I like easy. Also, as I continue to develop the rest of the tools I'll keep updating this post with the latest version and features just in case anyone would like to use them.

I've tested the heck out of this thing and it should not break any of your connections. But just to be safe, go ahead and test on a test scene first to make sure and let me know of any bugs.

Let me know if it helps!
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."


Last edited by Redsand1080 : 02 February 2012 at 06:30 AM. Reason: Updated jjj_gammaTools to v2.0
 
Old 07 July 2010   #2
Very nice! I've just tested it and it works great. I'll be using this one from now on .

PS: It also needs to affect light colours as well.

Last edited by TinyCerebellum : 07 July 2010 at 03:54 AM.
 
Old 07 July 2010   #3
Great job. Justin!!! Will test it for sure.
 
Old 07 July 2010   #4
@jasonhuang1115: Thanks Jason! Look forward to the feedback!

@TinyCerebellum: Thanks much for the positive feedback. I know I definitely like the features...which is the only reason I wrote it. I just got tired of constantly finding situations where I had to do things manually. I wanted something fully automated for my particular way of working. Glad others can benefit from it as well. Please elaborate on what you mean by 'light colors' and I'll work it in. Which are the shaders that have light colors and name a couple of the attrs that you would describe as 'light colors.' Thanks!

-Justin
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."

 
Old 07 July 2010   #5
I just mean the colour swatch for light objects (spot, point, directional, area, ambient, etc.). There are a number of colour swatches all over the place, in many other nodes too. However, lights get used almost as often as shaders. One other node that I can think of off the top of my head is the physical sun and sky node, with the ground and night colours, but it's not a huge deal.

Again, great job!

Last edited by TinyCerebellum : 07 July 2010 at 02:08 PM.
 
Old 07 July 2010   #6
Just curious to know why you have a ramp plug into the value of the gamma node when correcting the swatch colors.
 
Old 07 July 2010   #7
Originally Posted by TaKIKO: Just curious to know why you have a ramp plug into the value of the gamma node when correcting the swatch colors.


It's the only way I could think of to easily gamma correct my color swatches. It's just a work-a-round really...kind of a 'cheat' I guess. It was something I was doing manually for the longest time but just wanted it automated.

I thought about setting it up so that it would take the values in your color swatches and divide them all by .454 for you. There would be no need for an extra ramp node and gamma node in that case. But there were some immediate problems with that idea that I did not like for my particular way of working. Say I found the color I liked and then divided it by .454. Then I decided that color was just a little bit too saturated and I just wanted nudge the sat a little bit. Well, since I divided it by .454 it's not the same color anymore...so I can't just reduce that sat by .1 or whatever, I've got to go and re-make that color, reduce the sat, and then divide by .454 again. That's kind of annoying to me. But if I just store that color value in a ramp node and insert the gamma node between I can easily go back to that ramp node and change my original color.

There might be some more clever way to do it and I'm open to any ideas...it was just the first thing I thought of and fairly easy to implement so I just went with it.

So yea...in the end...it's just a cheat. If you have some clever ideas I'm all ears though!
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."

 
Old 07 July 2010   #8
Originally Posted by TinyCerebellum: I just mean the colour swatch for light objects (spot, point, directional, area, ambient, etc.). There are a number of colour swatches all over the place, in many other nodes too. However, lights get used almost as often as shaders. One other node that I can think of off the top of my head is the physical sun and sky node, with the ground and night colours, but it's not a huge deal.
Again, great job!


Thanks a lot! Glad you dig it. To be honest I've never thought about gamma correcting my light shaders. I've never heard of anyone gamma correcting light shaders before. Is that really a valid thing to do? The point about the MR Sun and Sky is an awesome idea though! I'm definitely going to include that now that you mention it.
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."

 
Old 07 July 2010   #9
Thanks a lot. Does it work with maya 2008??
I'm going to test it now!
 
Old 07 July 2010   #10
Actually, TaKIKO raises a good point. Normally we just change the colour swatch of the Value attribute in the gamma correct node, rather than plug in something like the ramp node into it. We can always go back and change that swatch the same way you'd do it in the ramp. The ramp is really not needed in this case, and perhaps it adds unnecessary computation time in most cases.

Regarding light objects, in my experience I found that gamma correcting the colour swatch makes a significant difference in getting a more predictable result.

I've also found a few things missing:
1: For attributes with an existing connection (such as an existing 2D texture-type node like ramp or noise), your tool does not update the connection by inserting the gamma correct node in between.

2.For the mia_material_x, the tool does not insert a gamma_correct node for the reflection, refraction, translucence(if enabled), and additional colour attributes.

3.For the standard materials like Blinn or Phong, same as above, the tool doesn't insert gamma_correct nodes for the transparency, ambient, incandescence, specular, reflected colour swatches.

For points 2 and 3, ideally, the tool would only update those swatches if they are different from the default black or white value. However, as it stands, the tool doesn't update them with a gamma_correct at all.
 
Old 07 July 2010   #11
Originally Posted by Redsand1080: ... I thought about setting it up so that it would take the values in your color swatches and divide them all by .454 for you. There would be no need for an extra ramp node and gamma node in that case. ....
I haven't check your script yet but if the calculations in it are based on dividing the RGB values by .454, this is wrong. The correct way is to use Gamma Correct node and change the values to 0.4545.

Applying gamma of 2.2 is taking the RGB values to the power of 2.2 which is not division.
 
Old 07 July 2010   #12
Originally Posted by Emil3d: I haven't check your script yet but if the calculations in it are based on dividing the RGB values by .454, this is wrong. The correct way is to use Gamma Correct node and change the values to 0.4545.

Applying gamma of 2.2 is taking the RGB values to the power of 2.2 which is not division.


Oops...I misspoke! You are right. My apologies. I meant _multiply_ by .454...not divide.

So basically a shade of grey = 0.5, 0.5, 0.5 turns into 0.227, 0.227, 0.227 with a gamma correction of .454. That should be correct.
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."


Last edited by Redsand1080 : 07 July 2010 at 05:22 PM.
 
Old 07 July 2010   #13
Originally Posted by TinyCerebellum: Actually, TaKIKO raises a good point. Normally we just change the colour swatch of the Value attribute in the gamma correct node, rather than plug in something like the ramp node into it. We can always go back and change that swatch the same way you'd do it in the ramp. The ramp is really not needed in this case, and perhaps it adds unnecessary computation time in most cases.


That is an excellent point. Man, I should have done that to begin with. I totally agree with both you. My current method is redundant. I'm going to change that in the next couple days.

Originally Posted by TinyCerebellum: Regarding light objects, in my experience I found that gamma correcting the colour swatch makes a significant difference in getting a more predictable result.


I'll check up on this to be sure. If that is a valid point I will definitely implement that as well. Thanks for bringing it to my attention.

Originally Posted by TinyCerebellum: I've also found a few things missing:
1: For attributes with an existing connection (such as an existing 2D texture-type node like ramp or noise), your tool does not update the connection by inserting the gamma correct node in between.


You are totally right. That is what the 'direct select' mode is for. It's a work-a-round for that scenario. I wrote about that in the little readMe file. I learned quite a bit about MEL as I was writing this and I now know I can extend the functionality to cover this scenario, so I'll work on that as well.


Originally Posted by TinyCerebellum: 2.For the mia_material_x, the tool does not insert a gamma_correct node for the reflection, refraction, translucence(if enabled), and additional colour attributes.


It really should work for the translucency color if it's enabled. It works for me just fine. I didn't do those other 2 because I asked Zap about gamma correcting those a while back and I'm pretty sure he said sometimes you may want to and sometimes not. I'll double check on that to be sure and if he says they should always be gamma corrected I'll make sure and add that.

Originally Posted by TinyCerebellum: 3.For the standard materials like Blinn or Phong, same as above, the tool doesn't insert gamma_correct nodes for the transparency, ambient, incandescence, specular, reflected colour swatches.


The only thing you are supposed to gamma correct out of all of those is the color attr. Never gamma correct your transparency or your specular. Perhaps the ambient, incandescence, and reflected color should be gamma corrected. I'll be honest and say I'm not 100% sure about that. I thought not, but I could be wrong. If anyone can confirm I'll add that as well. I'll ask Zap about that also.

Originally Posted by TinyCerebellum: For points 2 and 3, ideally, the tool would only update those swatches if they are different from the default black or white value. However, as it stands, the tool doesn't update them with a gamma_correct at all.


The translucency slot, if it is enabled, really should get gamma corrected. It works fine both on my computer at home, and also on my computer at work. Not sure what the deal is there. Can you confirm that if you click the check box 'Use Translucency' that the 'Color' box does not get updated correctly?

Thanks for the great feedback. This will help me to make this tool much better.
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."

 
Old 07 July 2010   #14
Originally Posted by JohnPetrucci: Thanks a lot. Does it work with maya 2008??
I'm going to test it now!


Yes it works great on 2008. I have 2010 at home and 2008 at work and always bring it in and test it out here at work.
__________________
If animation is the illusion of life, then life is the illusion of reality.


"On ne sort pas DU REVE."

 
Old 07 July 2010   #15
The cases that you're talking about, when the gamma correction probably shouldn't apply is when dealing with greyscale values only, such as a bump texture. However, as soon as the saturation is greater than 0, the situation changes.

I also tested the translucency for the mia_material, and it does indeed work. My mistake.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:22 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.