Notifications
Clear all

[Closed] Change gamma value?

Hi, first time here.

I am a begginer in maxscript (mostly modeling, texture, lighting guy), but i am trying to get into it as it seams very nice way to save time on some repetitive tasks. The only script i have made is a code that changes the default render engine in max to Vray (just one line of code).

Anyhow, we recently moved from linear color space to logarithmic so  sometimes we need to change texture input gamma from its default to 2.2, like here: [[img] http://img147.imageshack.us/img147/9046/gamma01ga6.th.png[/img]]( http://img147.imageshack.us/img147/9046/gamma01ga6.th.png[/img]](  g"/> )

Btw, we use this gamma setup:
http://www.aversis.be/tutorials/vray/essential_gamma_01.htm

If a file has several thousand objects and you have to change each texture…you see the problem. So i thought i would write a script that goes only into Diffuse bitmap (as far as i know, only diffuse map needs to be gamma corrected) and changes its gamma. Material after material.
Plus, it could test and correct textures that somebody just forgot to gamma correct.

I found out that you can’t do this directly, because help says:
[left]It is not possible to change the gamma or pixel aspect of a bitmap once created, though you can copy one bitmap into a newly created one that has a different gamma or pixel aspect to achieve this effect.
[/left]
[left]
I tried to create a temp variable that would store the bitmap and change its gamma and than overwrite the original bitmap, but right now its beyond my skills.

So it would really rock if someone could point me in right direction.

Sorry for my English.

[/left]

11 Replies

The quote from the help applies to MAXScript Bitmap Values, not to the Open Bitmap dialog’s override gamma settings which are, AFAIK, NOT accessible to MAXScript.
Even if you would save a new bitmap with a new gamma setting saved with the file, the open bitmap dialog is currently set to “Override” and not “Use Bitmap’s Own Gamma”, so it would change nothing.
This file picker was written before there was MAXScript to worry about and I am afraid none of its options are scriptable
Of course, I could be wrong.

Thanks for reply Bobo.

Ok, will have to do it manually or think of other gamma setup.
Anyhow, will try to learn maxscript to do some of “my” work.

 JHN

I don’t know which version of max you use, but maybe you can add a “mr Gamma & Gain” map between the diffuse and the texture map? Providing you use mental ray…
Or when not using MR then using the colorcorrect plugin to do the gamma for you…

Any help!?

Johan

Yeah, colourcorrect plugin is great, but its still additional stuff you have to do. We use vray and it has its own colour correct plugin, but again, that is even more work than just typing that 2.2 in that dialog box. Ok its not much, but i just want to get more efficient and it looks like it isn’t possible.
Anyhow, thanks for reply.

How is it more work if you’re intending on writing a script? It should save time because you wont have to worry about typing the 2.2 anymore

I guess i didn’t type it correctly (my lousy english :)). I meant that its not a big difference to type 2,2 in a dialog box for diffuses, or just use a new shader. Its all the same – a bit of hassle.
I hoped that there was a way to automatically type that number there.
btw guys, any idea how to add it via some utilities from windows or something like that? Just ‘‘shooting’’ in the darkness here.

Hi there, I started scripting this on Friday and I achieved something but it’s not yet finished. I created a new bitmap with the same width, height and added the gamma:0.4545(Inverse 2.2 gamma) then copied the current bitmap to the newly created and used “display thenewbitmap” and it worked ok if the current bitmap is loaded with a bitmap of 1.0 (other gamma would imply calculating the inverse gamma of that bitmap) but then I had to go home and I still havent finished, but it seems that after that I have to save the bitmap with a new name or overwrite the current one and then apply the new bitmap to the current diffusemap.

I hope I was clear, sorry about my english too Monday I’ll try posting what I have so we can talk about it and maybe someone comes with some better solution. Cyas!

Well I just proved Bobo is right lol I’ve made the gamma change, applied the new bitmap but Max overrides it


freescenebitmaps()
mtls=scenematerials
for i=1 to mtls.count do
(
themat=mtls[i]
case classof themat of
(
Standard:
(
thebitmap=themat.diffuseMap.bitmap
if thebitmap.gamma==1 then
(
	newgamma=1/2.2
)
else
(
	newgamma=1/thebitmap.gamma
)
thenewbitmap=bitmap thebitmap.width thebitmap.height filename:thebitmap.filename gamma:newgamma
 
rendermap themat.diffuseMap into:thenewbitmap
thebitmap=copy thenewbitmap
thebitmap.filename=getfilenamepath(thenewbitmap.filename)+getfilenamefile(thenewbitmap.filename)+"_gamma"+getfilenametype(thenewbitmap.filename)
save thebitmap
display thebitmap 
 
print thebitmap.gamma
themat.diffuseMap.bitmap=thebitmap
)
)
)

Thanks Kameleon for your effort, pitty it doesn’t work.
Will have to think of something else.

Page 1 / 2