By JTB
#340044
I have a large library of textures... arch mats, clipmaps for vegetation etc... I use forestpack pro from itoosoft and I like to have many materials for my plants, bushes, trees etc...
The script that follows is supposed to make maxwell materials with same characteristics easily... but it doesn't....
I can assign any float, boolean, RGB param but I can't assign texturemaps... I mean, I think I know how but
they don't appear... and they are not assigned correctly...

If someone can correct the following I would be very much obliged...

How it works...
I make 3 directories... maps1= diffuse maps... maps2= bump maps ..... maps3 = alpha maps...
Then two simple params alpha channel inverted or not, bumpmap= normalmap or not...
For example I have 5 diffuse maps and, 5 bumpmaps, 5 alphamaps... the names have to be almost the same so that they
are in the same order for all three folders.
So, d1,d2,...d5 b1..b5 a1....a5
I make a box and then 4 other copies... I select the boxes and then I run the script... then I have
box1->mat1 with d1,b1,a1 ...... box5->mat5 with d5,b5,a5....
Then I can export all mats or even export mxs, pack'n go, then export mxm...

Anyway, I know it is silly but I no nothing about maxscript and I think it is an easy solution for someone like me...
Like I said, my problem is that I can't assign the textures... Please help me , any tip would be really useful...

-- APPLICATION PARAMETERS
--file lists : dir1 diffuse, dir2 bump, dir3 alpha
dir1="c:/maps1/*.jpg"
dir2="c:/maps2/*.jpg"
dir3="c:/maps3/*.jpg"
-- general param if I have to invert alpha maps (dir 3)
invertmap=false
--check to see if the bump map is a normal map
normalbump=false
i=1
files1=getfiles(dir1)
files2=getfiles(dir2)
files3=getfiles(dir3)
--number of files
count=files1.count
-- make one box and then make copies as many as the files
sel=selection as array
for i=1 to count do
(
m=Maxwell_Material()
bmt1=bitmaptexture()
bmt1.filename=files1
bmt2=bitmaptexture()
bmt2.filename=files2
bmt3=bitmaptexture()
bmt3.filename=files3
m.name= i as string
m.layers[1].mask=bmt3
bmt3.output.invert=invertmap
m.layers[1].bsdfs[1].ReflectedColorTexture = bmt1
m.layers[1].bsdfs[1].ReflectedColor =color 165 100 200
print bmt1.bitmap
print bmt1.filename
print m.layers[1].bsdfs[1].ReflectedColorTexture
print m.layers[1].bsdfs[1].ReflectedColor
m.layers[1].bsdfs[1].BumpStrengthTexture = bmt2
m.layers[1].bsdfs[1].BumpStrength=30
m.layers[1].bsdfs[1].BumpAsNormalmap=normalbump
m.layers[1].bsdfs[1].Nd=1
m.layers[1].bsdfs[1].BumpStrengthTexture = bmt2
showtexturemap m bmt1 on
sel.material=m
i=i+1
)
#340069
The problem is that Maxwell Materials doesn't use BitmapTextures() for textures, it uses a custom node named MaxwellBitmap().
Here's is an example of how to create a maxwell material and assign a texture:
Code: Select all
m = Maxwell_Material()
bmt1 = Maxwell_Bitmap()
bmt1.FileName = "C:\a.jpg"
m.layers[1].bsdfs[1].ReflectedColorTexture = bmt1
So basically you need to change bitmaptexture() with Maxwell_Bitmap().

Also using "ShowProperties bmt1" will show all available properties for MaxwellBitmap() node. Here they are:
Code: Select all
  .FileName : filename
  .Channel : integer
  .TileType : integer
  .TileUnit : integer
  .TileX : float
  .TileY : float
  .OffsetX : float
  .OffsetY : float
  .Invert : boolean
  .Interpolation : boolean
  .Brightness : float
  .Contrast : float
  .Saturation : float
  .RGBClampMin : integer
  .RGBClampMax : integer
  .FlipX : boolean
  .FlipY : boolean
  .WideZ : boolean
  .Sequence : boolean
  .SequenceType : integer
  .SeqFirstFrame : integer
  .SeqLastFrame : integer
  .FrameOffset : integer
  .AlphaOnly : boolean
  .FramePadding : integer
  .FrameExt : integer
By JTB
#340099
Thank you!
I hope it works now... this is a great time saver for me...

I have ShaderMap (it is like Crazybump) and I can easily create bumpmaps, normalmaps etc... from images and I would like to work directly with MXMs instead of having to deal with huge image libraries...


UPDATE! It works great!!! Thank you once more...
By JTB
#340128
The finished script with some info...
Maybe it is useful for someone else... or... someone can use it as initial idea and make something better.

/*
Method for creating many materials
1. Create the 3 dirs with diffuse, bump, alpha map. No need to make dir2 if we don't
want or need bump files but we have to adjust the usebumpmap param. No need to make
dir3 if we don't have alphamaps.
2. Check if alphamap has to be inverted or if it is a tiff file then use the
same as diffuse map and change the alphaonly param.
3. Count the files and check that they have the correct order, size etc..
4. Open MAX and make (copies) as many boxes as the files in each dir.
5. Open the script file to check the above params
6. Select the boxes. (use Ctrl+A)
7. Run the script - now you must have the mats assigned to the boxes
8. Export to MXS using Pack & Go
9. Open MXS with Studio and use a low quality (3-4) for preview. Select all mats,
use right-click and recalculate previews.
10. Save MXS to update with the previews and go to mat editor and Extract from MXS
11. Now we have a dir with all MXMs and maps... Copy as we want it.
*/
-- APPLICATION PARAMETERS
--file lists : dir1 diffuse, dir2 bump, dir3 alpha
dir1="d:/maps1/*.*"
dir2="d:/maps2/*.*"
dir3="d:/maps3/*.*"
--Check what we use... bump, alpha, both...
usebumpmap=false
usealphamap=TRUE
-- general param if I have to invert alpha maps (dir 3)
invertmap=FALSE
--Check if alpha only for TIFF or PNG files
alphaonlymap=false
--check to see if the bump map is a normal map and how much bump I want
normalbump=false
howmuchbump== 30
--Let's go!
i=1
files1=getfiles(dir1)
files2=getfiles(dir2)
files3=getfiles(dir3)
--number of files
count=files1.count
-- make one box and then make copies as many as the files
sel=selection as array
for i=1 to count do
(
m=Maxwell_Material()
bmt1=Maxwell_Bitmap()
bmt1.filename=files1
if usebumpmap==true
then
(bmt2=Maxwell_Bitmap()
bmt2.filename=files2)
if usealphamap=true
then
(bmt3=Maxwell_Bitmap()
bmt3.filename=files3)
m.name= i as string
m.layers[1].bsdfs[1].ReflectedColorTexture = bmt1
/* m.layers[1].bsdfs[1].ReflectedColor =color 165 100 200 No need for this anymore
print bmt1.filename No need for this anymore
print m.layers[1].bsdfs[1].ReflectedColorTexture No need for this anymore
print m.layers[1].bsdfs[1].ReflectedColor No need for this anymore */
-- Now we see what we have to create or not
if usealphamap=true then
(m.layers[1].mask=bmt3
bmt3.invert=invertmap
bmt3.alphaonly=alphaonlymap)
if usebumpmap==true then
(m.layers[1].bsdfs[1].BumpStrengthTexture = bmt2
m.layers[1].bsdfs[1].BumpStrength=howmuchbump
m.layers[1].bsdfs[1].BumpAsNormalmap=normalbump)
m.layers[1].bsdfs[1].Nd=1
m.layers[1].bsdfs[1].BumpStrengthTexture = bmt2
showtexturemap m bmt1 on
sel.material=m
i=i+1
)
Help with swimming pool water

Hi Andreas " I would say the above "fake[…]

render engines and Maxwell

Other rendering engines are evolving day by day, m[…]