Jump to content

Color correcting multiple materials at once?


Kirsten Zirngibl
 Share

Recommended Posts

Hi,

 

I have a crapload of unique materials in my scene, and wish to go in and shift the hue/brightness for a bunch of them (but not all of them). Some of them are are multi/sub object materials, others aren't.

I realize I can shift+drag the color correct map within the Slate Editor to copy it, then de-link it and apply it to another map, but I need to do this with so many materials that it would get really tedious. (Why no right click copy-> paste for maps at least?)

 

 

I've searched Scriptspot but nothing working so far...

 

I tried the "ColorCorrect" plugin, but that only seems to be work for one diffuse map at a time which defeats the purpose, and I hear it has memory leak issues. Also there's no version of it for my version of Max (2014).

 

I also found this script. It's designed for Vray though, which I don't use.

 

 

My dream, as partially described in the 2nd link, would be the ability to select several objects and then run some kind of utility that applies a color correction map to each diffuse map... and then shifts the hue/sat/brightness/curves of ALL of them, ideally with some kind of slider UI.

 

 

Even if I can't do this via scripts, seems like there should be a way to apply a color correct to all the materials within a multi/sub object at LEAST. I'm actually really surprised there isn't a native way to do this in Max. (Or maybe there is, I'm admittedly a texture noob.)

 

 

Thanks in advance.

 

 

EDIT: Got a script. Posting here for any future folks with this need. (Thanks u/Heilandzack over on r/maxscript!)

 

Also, for an alpha map version, I went through the code and substituted "diffuse" with "opacity" and it totally works. :)

 

/*

--------------- color correct materials for selected objects -----------------

Should work for standard and multisub-materials

Flow:

Get materials from selected objects
if there is a mutlimat, get all submats instead and remove the mutlimat itself
remove duplicates from array
if there is a map in the diffuse channel, create a new cc node with the new settings and use the diffusemap as source
assign the cc node to the diffuse slot

*/

--- get materials from selection
mymaterials = #()
for obj in selection do
(
   if obj.material != undefined do appendifunique mymaterials obj.material
)

--- check for multisubmtls and collect the submtls
mysubmaterials = #()
for a=1 to mymaterials.count do
(
   if classof mymaterials[a] == Multimaterial then -- if multisubmtl, then
   (
       for b=1 to mymaterials[a].materialList.count do --- loop through submtls
       (
           if mymaterials[a].materialList[b] != undefined then appendifunique mysubmaterials mymaterials[a].materialList[b] -- collect submtls
       )
   )
)

-- delete multisubs from matarray
for a=mymaterials.count to 1 by -1 do
(
   if classof mymaterials[a] == Multimaterial then deleteitem mymaterials a
)

-- append the submtls
for a=1 to mysubmaterials.count do
(
   appendifunique mymaterials mysubmaterials[a]
)

print mymaterials

-- see whats in the diffuse slot
for mymaterial in mymaterials do
(
   -- make sure its a standard material
   if classof mymaterial == Standardmaterial then
   (
       --- make sure the diffuse slot is not empty
       if mymaterial.diffuseMap != undefined then
       (
           -- remember the map in the diffuse slot
           mymap = mymaterial.diffuseMap

           -- create a new cc node and wire it
           ccnode = ColorCorrection()
           ccnode.Map = mymap

           -- set cc settings
           ccnode.hueShift = 0.0
           ccnode.saturation = 0.0
           ccnode.tint = (color 0 0 0)
           ccnode.tintStrength = 0.0
           /*
           ccnode.rewireMode (Rewire_Mode) : integer
           ccnode.rewireR : integer
           ccnode.rewireG : integer
           ccnode.rewireB : integer
           ccnode.rewireA : integer
           ccnode.hueShift : float
           ccnode.saturation : float
           ccnode.tint (Hue_Tint) : fRGBA color
           ccnode.tintStrength (Hue_Strength) : float
           ccnode.lightnessMode : integer
           ccnode.contrast : float
           ccnode.brightness : float
           ccnode.exposureMode (Lightness) : integer
           ccnode.enableR : boolean
           ccnode.enableG : boolean
           ccnode.enableB : boolean
           ccnode.gainRGB (LightnessGainRGB) : float
           ccnode.gainR (LightnessGainR) : float
           ccnode.gainG (LightnessGainG) : float
           ccnode.gainB (LightnessGainB) : float
           ccnode.gammaRGB (LightnessGammaRGB) : float
           ccnode.gammaR (LightnessGammaR) : float
           ccnode.gammaG (LightnessGammaG) : float
           ccnode.gammaB (LightnessGammaB) : float
           ccnode.pivotRGB (LightnessPivotRGB) : float
           ccnode.pivotR (LightnessPivotR) : float
           ccnode.pivotG (LightnessPivotG) : float
           ccnode.pivotB (LightnessPivotB) : float
           ccnode.liftRGB (LightnessLiftRGB) : float
           ccnode.liftR (LightnessLiftR) : float
           ccnode.liftG (LightnessLiftG) : float
           ccnode.liftB (LightnessLiftB) : float
           ccnode.printerLights (LightnessPrinter) : float
             */

           -- put the cc node to the diffuse slot
           mymaterial.diffuseMap = ccnode
       )
       else print "nothing in diffuse slot"
   )
)

Edited by kirstenzirngibl
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...