WesMcDermott

01-29-2008, 05:41 PM

HI,

I am trying to write an expression to modify the color channel of a blinn shader. I am new to using MEL, so I'd appreciate some help. I am trying to linearize the color values that were chosen with the color picker. Using this formula

x = 255 * (x / 255) ^ gamma

where gamma = 2.2 for my monitor space

I have added an expression to the Color channel and I'm trying to change the formula to work in mel. Here is what I have.

$cR = 255*pow((blinn1.colorR/255),2.2);

$cG = 255*pow((blinn1.colorG/255),2.2);

$cB = 255*pow((blinn1.colorB/255),2.2);

setAttr "blinn1.color" -type double3 $cR $cBG $cB;

When I create the expression, the color channel is modified but it's turned black 0,0,0.

I know this formula is correct since I've used it in other 3D applications with perfect results.

If I manually use the forumula with a calculator and type in my color values from the blinn color channel, I get the corrected color value which appears as a darker green.

Original color values 40,119,13 after using formula on each RGB channel I get 4,48,0.

I don't understand why I'm getting 0,0,0 instead of 4,48,0 when using the above mel expression. Can someone please help me to understand what I'm missing?

thanks,

Wes

I am trying to write an expression to modify the color channel of a blinn shader. I am new to using MEL, so I'd appreciate some help. I am trying to linearize the color values that were chosen with the color picker. Using this formula

x = 255 * (x / 255) ^ gamma

where gamma = 2.2 for my monitor space

I have added an expression to the Color channel and I'm trying to change the formula to work in mel. Here is what I have.

$cR = 255*pow((blinn1.colorR/255),2.2);

$cG = 255*pow((blinn1.colorG/255),2.2);

$cB = 255*pow((blinn1.colorB/255),2.2);

setAttr "blinn1.color" -type double3 $cR $cBG $cB;

When I create the expression, the color channel is modified but it's turned black 0,0,0.

I know this formula is correct since I've used it in other 3D applications with perfect results.

If I manually use the forumula with a calculator and type in my color values from the blinn color channel, I get the corrected color value which appears as a darker green.

Original color values 40,119,13 after using formula on each RGB channel I get 4,48,0.

I don't understand why I'm getting 0,0,0 instead of 4,48,0 when using the above mel expression. Can someone please help me to understand what I'm missing?

thanks,

Wes