ScriptSpot

Forum topic · Scripts Wanted

Copy diffuse slot map to bump slot...

By roamn · 2012-03-04

Description

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 (7)

vinyvince · 2017-08-27

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

vincent
bout.de.lune@gmail.com

yes...

roamn · 2012-03-29

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 · 2012-03-12

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 :-)!

Problem found.

Garp · 2012-03-12

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 · 2012-03-11

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?

This should work:

Garp · 2012-03-06

(
    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
)

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

pfbelesa · 2012-03-29

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?