Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(36 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

MAXScript. How to COPY maps in material editor?
show user profile  Dave
Howdy folks! I'd almost managed to go a whole day of scripting without asking for help, and just when I thought I'd gotten it all working I stumble across a slight issue.

I'm trying to duplicate the bitmap in the diffuse channel, and put it in the opacity channel (where I'll also make some other changes to it)... but, no matter what I try, the end result always appears to be an instanced map... which is utterly useless as whatever changes I make to the opacity map, will mirror into the diffuse, and vice versa. Here's what I ended up with:

on alphaGoGo pressed do
mtl = meditMaterials[activeMeditSlot]
for m in mtl do
m.opacityMap = copy m.diffuseMap

(This only works on multi/sub-object materials, I have an else statement for dealing with regular/single standard materials, but figured I'd keep it simple for the forums.)

As you can see, I used copy, but it doesn't create a copy, it creates an instance, can anyone help me out here?

"I flew over Egypt once"

read 2713 times
11/16/2011 1:15:02 PM (last edit: 11/16/2011 1:15:02 PM)
show user profile  reeves1984
is the maxscript/sdk help online?

Like this...

Simon Reeves - VFX Artist & Blog
twitter <-- I work here

read 2707 times
11/16/2011 1:49:18 PM (last edit: 11/16/2011 1:49:18 PM)
show user profile  Dave
Yar, that was how I ended up using copy. I've been reading through the help a lot but I just don't know what I'm looking for.

"I flew over Egypt once"

read 2703 times
11/16/2011 1:56:59 PM (last edit: 11/16/2011 1:56:59 PM)
show user profile  br0t
Mhm your code doesnt work for me. One thing is you forgot to close the btn event handler, but thats not the thing: You are referencing the current selected material as "mtl". And then your loop over that single material? Cant do that, throws me a "No map function for ..." error.
If I just type:

mtl = meditMaterials[activeMeditSlot]
mtl.opacityMap = copy mtl.diffuseMap

everything works fine for me. Maybe your problem lies in something else?

never get low & slow & out of ideas

read 2688 times
11/16/2011 4:17:16 PM (last edit: 11/16/2011 4:17:16 PM)
show user profile  Dave
br0t, no the single material is currently dealt with as you've just done yours, I said in my original post that my script was for multi/sub object materials, I use an else for dealing with the single materials.

Also, if you check your script... it creates an instance, not a unique copy. Which is what I'm trying to achieve here.

Cheers though.

"I flew over Egypt once"

read 2685 times
11/16/2011 4:21:13 PM (last edit: 11/16/2011 4:21:13 PM)
show user profile  br0t
Ah i overread that multi/subobject thing. Anyways, for me it does NOT create an instance, but a copy Oo"

never get low & slow & out of ideas

read 2676 times
11/16/2011 5:06:56 PM (last edit: 11/16/2011 5:06:56 PM)
show user profile  Dave
Oh cocklenuts, I wasn't setting the monoOutput on the opacity map to alpha (1) so I just THOUGHT it was instancing the diffuse. Good job you came along br0t, I definitely would have kept skipping over that. Full code:

mtl = meditMaterials[activeMeditSlot]
if getNumSubMtls meditMaterials[activeMeditSlot] == 0 do
mtl.opacityMap = copy mtl.diffuseMap
mtl.opacityMap.alphaSource = 0
mtl.opacityMap.monoOutput = 1
mtl.diffuseMap.alphaSource = 2
if getNumSubMtls meditMaterials[activeMeditSlot] > 1 do
for m in mtl do
m.opacityMap = copy m.diffuseMap
m.opacityMap.alphaSource = 0
mtl.opacityMap.monoOutput = 1
m.diffuseMap.alphaSource = 2

Next up... trying to do it based on object selection as opposed to material slot selection. But that's much less of a concern!

Must remember to grab the html code off one of Garps post for posting scripts.

"I flew over Egypt once"

read 2674 times
11/16/2011 5:19:47 PM (last edit: 11/16/2011 5:23:51 PM)
show user profile  Garp
Here you go, Dave: here

Save it to your usermacros folder and in the customize ui dilaog, set it somewhere (I put it under the maxscript menu).
To use it, you need to select and copy your code (to send it to the windows clipboard) and then run 'wrap for MF' from the menu (or button or whatever).
You'll also need to untick the 'convert to html' box inMF's reply dialog. Which also means that you'll have to add 'br' tags in your text (not the code, your post) ;)

Spoon, any chance of integrated this some day? 'code'and 'text' tags do not work properly.

read 2663 times
11/16/2011 9:56:50 PM (last edit: 11/16/2011 10:21:08 PM)
show user profile  br0t
glad you found a solution Dave!

never get low & slow & out of ideas

read 2647 times
11/16/2011 11:01:32 PM (last edit: 11/16/2011 11:01:32 PM)
show user profile  Dave
Nice one Garp!

"I flew over Egypt once"

read 2636 times
11/17/2011 11:08:59 AM (last edit: 11/17/2011 11:08:59 AM)
#Maxforums IRC
Open chat window