|Gamma Correcting for every texture or colour swatch in a large shader network can be a chore|
I've recently begun the search in earnest for useful maya scripts that can help cut down on repetitive tasks. One such gem I've stumbled across is a very helpful 'gammaCorrect' node generating utility, which becomes extremely useful when working within a linear workflow in Maya. This tool automates the process of inserting gammaCorrect nodes wherever required in a shader network- specifically on colour swatches and 8 bit textures, in order to remove the encoded gamma of 2.2 and allowing them to render correctly in linear space.
(If you're unfamiliar with linear workflow, I'd highly recommend becoming aquainted with the subject. It's super important...)*
Here is the MEL script...
(requires registration with the Creative Crash site)
Once downloaded, the script will need to be extracted into your local maya scripts directory. For most users, that will be located under Documents\Maya\(maya version)\scripts. With that done, you should be able to access the utility by typing 'jjj_gammaTools' into the MEL command line at the bottom of the Maya UI. Alternatively and perhaps preferably, you can create a new custom shelf icon via the Maya Shelf Editor that when clicked, runs the script automatically (make sure to add the line 'jjj_gammaTools' in the command tab of the Shelf Editor).
The default maya gamma icon only comes in .svg format and is unsuitable as a shelf icon, so below I've provided a custom .png icon with transparency that you can use instead (right click: Save image as...). Icons generally go in the Documents\Maya\(Maya version)\prefs\icons folder.
|Setting up a new custom shelf item in the Shelf Editor|
|My new best friend...|
Once you've set up a new custom shelf item, you'll have a one button solution to managing your textures and colour swatches under a linear workflow. This is as simple as selecting a shader, running the jjj_gammaTools script (whether from the shelf or MEL command line) and clicking the 'update Selected' button in the popup UI. The script will work its magic and automatically insert gamma correct nodes (with a gamma of .454) wherever needed in your shader network. If you have tons of shaders you need to gamma correct for, then the 'Update All Shaders' button will do the job for you in no time at all. Essentially, extremely cool!
* Explanation of linear workflow is beyond the scope and purpose of this blog post. There are lots of great resources on the web which cover linear workflow and why it is important when working in 3d. Here's a partial list: