Copy diffuse slot map to bump slot...

Could you please help me with a simple script, which copies the map present in the diffuse slot to the bump slot of the same material? BUT it needs to work, both with mutltisubojects materials and also with vray materials...

So far i have this:

macroScript Bla
category:"MY"
toolTip:"Bla"
(
with undo "Map Copy" on
(
for obj in selection do
(
try(obj.material.bumpMap = copy obj.material.diffuseMap) catch()
)
)
)

But this works only on the standard materials. It doesnt work on vray materials and also it doesnt work on multisuboject materials. Could you help me please to get pass this problem?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vinyvince's picture

Doesn t work on max 2017 and

Doesn t work on max 2017 and latest vray unfortunately...

vincent
[email protected]

roamn's picture

yes...

Well yes, i gues, just apply to multimaterial do some object on the scene, it should do the job. (select then the object and run the script)

roamn's picture

Thanks, ill try it. (I have

Thanks, ill try it. (I have max 2009 64 bit).
Just a little note for those of you, who might find this script also usefull:
Its better to add there the word "copy".

e.g.

mtl.texmap_bump = COPY mtl.texmap_diffuse

Otherwise the bump map is an instanced map, and if you want to change something in the diffuse slot only (i change mainly the blur to a lower values), then it affects also the bump slot, which is not good.

But anyway BIG thank you to you :-), im not skilled in maxscript, so i would be unable to write the script myself. Thanks :-)!

Garp's picture

Problem found.

It works fine in max 2012, so I tested it in old max 9 and, well, it fails.
Apparently, the hasProperty() method is wonky. If I grab a standard material, showProperty mtl shows a diffuseMap property, mtl.diffuseMap accesses it but hasProperty mtl "diffuseMap" returns false. What the heck?!
Here's a variation that works both in max 9 32-bit and max 2012 64-bit, so it 'should' work with anything in between:

(
    local all_mtls = #()
 
    for obj in selection where (mtl = obj.material) != undefined do
        if classOf mtl == multiMaterial then
            for m in mtl.materialList do append all_mtls m
        else
            append all_mtls mtl
 
    for mtl in all_mtls do
        case classOf mtl of (
            vrayMtl: mtl.texmap_bump = mtl.texmap_diffuse
            standardMaterial: mtl.bumpMap = mtl.diffuseMap
        )
)
roamn's picture

Thanks, but now it works only

Thanks, but now it works only for vray materials and mutlimaterial with vraymaterials as suboject materials...

It does not work on standard materials and mutlisuboject material with standard materials as subojects...

Anyone can help?

Garp's picture

This should work:

(
    local all_mtls = #()
 
    for obj in selection where (mtl = obj.material) != undefined do
        if classOf mtl == multiMaterial then
            for m in mtl.materialList do append all_mtls m
        else
            append all_mtls mtl
 
    for mtl in all_mtls do
        if hasProperty mtl "texmap_diffuse"  then   -- vray
            mtl.texmap_bump = mtl.texmap_diffuse
        else if hasProperty mtl "diffuseMap"  do
            mtl.bumpMap = mtl.diffuseMap
)
pfbelesa's picture

Can it be done in a map already in the material editor

I have an multimaterial in the material editor, can i use something like what you did to copy all diffuse maps on the submaterials do bump maps?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.