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

Maxunderground news unavailable

Need to systematically map a LOT of textures - smartest way to do it?
show user profile  Stenrik

I'm working on an interesting project but I have a ton of tedium ahead of me if I don't find a better way to accomplish it.

I have bunch of equally sized planes. Each one needs a unique ambient map, alpha map, and displacement map. The mapping is simple:
--The planes are square.
--The map images are square.
--I just need to "fill" each plane with the 3 unique map images.

The material editor has a limit of 24 visible materials. (Argh, why so low?) I know I'm not limited to the amount of texture maps in my scene (at least I don't think so) but it's hard to manage.
I find the Slate material editor to be a pain in its own way, since it requires so much dragging, rearranging, and clicking. I also keep accidentally overwriting old texture maps with new ones with it.

Is there a good script/plugin for mapping lots of unique textures to objects?
Ideally something that would let me set up some kind of "name-matching." (Like if I have a plane called "Plane 005" it would scan my map folder and look for "Alpha 005" and put it in the Alpha slot, same for Ambient and Displacement. With careful naming, this would be awesome!)

If not, I'd settle with the ability to pull ALL unique planes into the Slate material editor and auto-arrange the panels. That would at least save some time.

I plan to do this with thousands of textures, so I'm willing to go through some work to set up a better way to do this! I'm even willing to learn what I need to in MAXscript to make that happen, but I'm not sure it's even possible.

read 515 times
8/3/2015 4:41:33 AM (last edit: 8/3/2015 4:48:25 AM)
show user profile  Garp
I'm going for the simplest case.
- each object's name is of the form PlaneXXX (where XXX is a number)
- for each of them there are corresponding images DiffuseXXX.jpg and AlphaXXX.jpg

This should get you started:

read 490 times
8/3/2015 5:58:44 AM (last edit: 8/3/2015 6:15:46 AM)
show user profile  Stenrik
This works beautifully! Thank you so much, Garp, you've saved me me a lot of time (and convinced me it's time to really learn how to make Maxscripts from scratch). If I knew you in real life I'd buy you dinner!

I did add "mat.displacementMap" into it and got some wonky results, but not sure if it's the script or my maps, though they LOOK fine. It's definitely doing something, so I know the command exists. No errors or anything like that. I'll try some variations and get back if I can figure out.

read 473 times
8/3/2015 9:20:48 AM (last edit: 8/3/2015 9:24:23 AM)
show user profile  Bolteon
Garp ftw.

-Marko Mandaric

read 464 times
8/3/2015 9:53:24 AM (last edit: 8/3/2015 9:53:24 AM)
show user profile  Garp
Yay :)

read 449 times
8/3/2015 3:52:10 PM (last edit: 8/3/2015 3:52:10 PM)
show user profile  Stenrik
I have an addendum to this topic.

First off, I realized I'd need to make some of these double-sided. I simply added "meditMaterials[22].twoSided = on" to the last line after "p.material = mat."

It seems to be working, though with a mystery:

When I use the eyedropper within the Material Editor to actually bring in one of my maps, the "2-sided" box is NOT checked. Even though it ACTS 2-sided.
I also realized that no matter which plane's material I bring into the editor, it always says that it is mapped with "Alpha001"/"Diffuse001" when it should in reality be something like "Alpha018"/"Diffuse018."

I'm having a hard time understanding how mapping planes with a script is different than doing everything through the material editor. I'd like to better understand the differences. In fact, it's pretty important in the cases in which I need to go in and tweak things for one plane.


One other thing - I'd imagine there's a way to gradually vary the opacity of each plane?

Say I have "Plane001 - Plane 020"
I want to vary the total opacity of each plane so that Plane001 is completely opaque, and Plane 020 is completely transparent, with a gradient of steps in between.
I envision the script would take "100" and divide it by the number of planes in the stack. It would find that it needs to step down the opacity by 5% for each layer. It would do this based on layer name. For example, the lowest number within the plane name always has the highest opacity assigned to it.
So "Plane 10" would be 50% opacity, "Plane 15" would be 25% opacity, etc...

Ideally it would be a separate script that only applies this effect to the planes currently selected. This is actually pretty important, as I'd have a bunch of planes in the whole scene I don't want to do this with.

I can see this getting hairy though. I don't know how intelligent Maxscript is when it comes to prioritizing functions based on name. In your original script, there was no specified order, just 1-to-1 matching.
The other thing I see being problematic is decimal handling. If I have an odd number of planes, I would hope that Max could round them. Say I have selected 65 planes. That means that they need to vary in opacity by 1.54% each step. I assume Max would just round them and call it a day, but since scripting textures seems to be independent from the material editor, I'm not sure.

Looking forward to any insight. Thanks!


read 387 times
8/16/2015 4:41:45 AM (last edit: 8/16/2015 5:04:03 AM)
show user profile  Garp
Just a quik reply since I'm in a rush.

meditMaterials[22] acts on the material editor. If you do it inside the loop, you're going to change the same material each time around.
If you want to affect all the planes, use mat directly.
If you want to act only on some of them, I dunno. You could store the specific plane names in an array and then test inside the loop if the current plane is in it or not.
About the eyedropper thing, I've no idea.

Concerning the opacity.
If you have N planes, you want to divide the range by N-1, not N. E.g. if you had 2 planes, you'd want 100% between the 2. If you had 3, then 50% (0, 50 and 100). Etc.
The question is do you want the variation to be based on the number of planes or on the actual number in their names? If you have Plane001, Plane002 and Plane005, do you want (0%, 50%, 100%) or (0%, 25%, 100%)?
I don't get what you mean with the odd number of planes. mxs can deal with floating point values just fine.

read 372 times
8/16/2015 6:19:21 AM (last edit: 8/16/2015 6:19:21 AM)
#Maxforums IRC
Open chat window