Dividing diffuse by .454


#1

Hi,

With the release of V-Ray 3.3 - it now supports Maya’s colour management :bowdown:

However this means I have a few assets that are still using the old linear workflow tickbox and converting these colours manually will take a long time.

Does anyone know a script that can divide the R G B values of a material’s diffuse by .454? Of course one can attach a gammaCorrect node via script but that breaks the viewport more often than not.


#2

Its a long while since I needed to think about that kind of stuff, but simply dividing by a fixed constant doesn’t seem right to me. You’d you need to look up a gamma function I think? I may have even done that once before. If no one beats me to it, and if I can dig up my old code, I’ll report back.

David

edit:

This is not a complete ready to go script, but it might be something you can start with.
Select materials that you want to adjust and run this python. I’m assuming whatever is selected has an attr called “color”.

import pymel.core as pm
for m in pm.selected():
    c = m.color
    c.set([pm.datatypes.gamma(x,2.2) for x in c.get()])

David


#3

:bowdown:

I have to stop trying to do things in MEL I think. Great help again djx, thank you.