Hi,
Whenever i try to change the baseColor of corona materials via maxscript, the values end up being input in linear by default. Im assuming this is because of the way max internally handles colors and the conversion between rgb 255 and rgb 0-1. How can i ensure theyre added in sRGB or how can i convert the values correctly?
for instance color 250,200,10. If i manually add it into the picker in srgb mode the colour is correct.
However when i add it via maxscript it adds it in linear mode and so the resulting srgb colour is 254,228,59
How can i fix this? Is there a formula i need to implement in my script or do i need a different approach?
I tried using the max standard color map but the same thing happens even if i set the gamma to 1.0. It has to be to do with the way maxscript handles the (color R G B) values internally.
Thanks!
EDIT: The solution was to gamma correct the sRGB colours
Heres a function
fn adjustColorGamma _inputColor _maxVal _gammaVal _doInverse =
(
if _doInverse then
(
outputR = _maxVal * ((_inputColor.r/_maxVal)^(1.0/_gammaVal))
outputG = _maxVal * ((_inputColor.g/_maxVal)^(1.0/_gammaVal))
outputB = _maxVal * ((_inputColor.b/_maxVal)^(1.0/_gammaVal))
(color outputR outputG outputB)
) else
(
outputR = _maxVal * ((_inputColor.r/_maxVal)^_gammaVal)
outputG = _maxVal * ((_inputColor.g/_maxVal)^_gammaVal)
outputB = _maxVal * ((_inputColor.b/_maxVal)^_gammaVal)
(color outputR outputG outputB)
)
)
adjustColorGamma (color 255 255 255) 255 2.2 false