Hi I'm a new at using MAXScript, and I need to replace a lot of Normal Bump maps in my scene. I imported some models and they have a Multimaterial with several VrayMtl on them, and in some of those VrayMtls there is a Normal Bump map which I need to replace with a VrayNormalMap with the same Bitmap as before.
I searched the forums and someone had a similar problem (actually was the exact opposite), and I found a script that replaces VrayNormalMap with a Normal Bump map, so I tryed to tweak it to do the inverse, but I can't seem to make it work. I believe I need to specify that it is inside a multimaterial, and then a VrayMtl submaterial, but now I'm totally lost.
Any help would be really aprecciated.
This is the script I found earlier from barigazy:
try(destroydialog ::vrnRoll) catch()
rollout vrnRoll " VrayNormalMap Convertor" width:168 height:30
(
fn filterNMap obj =
(
isKindOf obj.material VRayMtl and \
isKindOf obj.material.texmap_bump VRayNormalMap and \
isKindOf obj.material.texmap_bump.normal_map Bitmaptex and \
obj.material.texmap_bump.normal_map.filename != undefined
)
button btn "VrayNormalMap to NormalMap"
on btn pressed do
(
if (getClassInstances VRayNormalMap).count != 0 do
(
local objMtlsArr = for g in geometry where filterNMap g collect g.material
if objMtlsArr.count != 0 do
(
for m in objMtlsArr do
(
local NMap = Normal_Bump name:(m.texmap_bump.name) normal_map:(m.texmap_bump.normal_map)
m.texmap_bump = NMap
)
free objMtlsArr
)
)
)
)
createDialog vrnRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
Comments (9)
Comment policy
VrayLighrMtl Material to VrayMtl Material
Hello,
I would be appreciated if someone help me to make the script above to convert VrayLighrMtl Material to VrayMtl Material.
Pleaaaaase!
Would be possible change also a Gamma to 1.0?
Hi!
Its great script! Might you know there is a bug with Vray and normal bump in proxy objects. So all proxy objects has to have material with vraynormalmap, not with normalbump and this script is a solution.
I would be very pleased to have also an option to load every bitmap in converted vraynormalmap with gamma 1.0 in 3DS Max 2010 :) Pleasssss :)
Thanks
Nevermind, I found the error, a couple of materials had no bitmap assigned to the Normal Bump, thats where it crashed.
In any other case it works perfectly! Thanks again barigazy!!
Try this
try(destroydialog ::vrnRoll) catch()
rollout vrnRoll "NormalMap Convertor" width:168 height:30
(
button btn "NormalMap to VrayNormalMap"
fn getMaterial arr = for i in arr where isKindOf i VRayMtl collect i
on btn pressed do
(
for g in geometry where g.mat != undefined and (ins = getClassInstances Normal_Bump target:g.mat).count != 0 do
(
for m in ins where (isKindOf m.Normal_map Bitmaptex) do
(
NMap = VRayNormalMap name:(m.name) normal_map:(m.Normal_map)
if (arr = getMaterial (refs.dependents m.Normal_map)).count > 0 do (for n in arr do n.texmap_bump = NMap)
)
)
)
)
createDialog vrnRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
Yeah, I tried that same thing, but it doesn't work. It returns a dialog that reads:
On the Listener it reads the following:
send me test scene for testing
try(destroydialog ::vrnRoll) catch()
rollout vrnRoll "NormalMap Convertor" width:168 height:30
(
button btn "NormalMap to VrayNormalMap"
fn getMaterial arr = for i in arr where isKindOf i VRayMtl collect i
on btn pressed do
(
for g in geometry where g.mat != undefined and (ins = getClassInstances Normal_Bump target:g.mat).count != 0 do
(
for m in ins do
(
NMap = VRayNormalMap name:(m.name)
if isKindOf m.Normal_map Bitmaptex do NMap.normal_map = m.Normal_map
if (arr = getMaterial (refs.dependents m.Normal_map)).count > 0 do (for n in arr do n.texmap_bump = NMap)
)
)
)
)
createDialog vrnRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
Thanks barigazy!! but your script does the opposite of what I want, it replaces any VrayNormalMap with a Normal Bump.
I need every Normal Bump replaced with a VrayNormalMap.
try(destroydialog ::vrnRoll) catch()
rollout vrnRoll " VrayNormalMap Convertor" width:168 height:30
(
button btn "VrayNormalMap to NormalMap"
fn getMaterial arr = for i in arr where isKindOf i VRayMtl collect i
on btn pressed do
(
for g in geometry where g.mat != undefined and (ins = getClassInstances VRayNormalMap target:g.mat).count != 0 do
(
for m in ins do
(
NMap = Normal_Bump name:(m.name)
if isKindOf m.Normal_map Bitmaptex do NMap.normal_map = m.Normal_map
if (arr = getMaterial (refs.dependents m.Normal_map)).count > 0 do (for n in arr do n.texmap_bump = NMap)
)
)
)
)
createDialog vrnRoll style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)