[Closed] create 100 shader with maxscript
Hi,
i´m new to maxscript but have good experience in mel scripting. my problem now is i have to make 100 or more shader with each having an other bitmap in the diffuse channel.
for time saving, i want to script those shader but i really don´t know how and couldn´t find anthing about creating shader in the web. could anybody give me a hint?
By shaders do you mean creating Materials ?
If yes, here is the way i would do my script.
Create your Material and apply it to an object in the scene.
Go To Mascript -> new script
then you can access your material like this
M = sceneMaterials[#YourMaterialName]
Then you want propably create an array containing the bitmap filenames.
files = getFiles "C:/yourBitmapDirectory/*.tga"
After that you can loop into this array in wich you will duplicate your original material and change the diffuse map :
for i=1 to files.count do (
newMat = copy M
newMat.name = M.name+"_"+(getfilenamefile files[i])
NewMat.diffusemap = Bitmaptexture fileName:files[i] apply:true
showTextureMap NewMat on
S = sphere pos:[i*2.2,0,0] radius:1 segments:8
S.material = NewMat
)
The script make a sphere to see the result of the materials created.
If the materials are applied to objects you can access them with “sceneMaterials”
Here is the complete Script
M = sceneMaterials[#YourMaterialName]
files = getFiles "C:/yourBitmapDirectory/*.tga"
for i=1 to files.count do (
newMat = copy M
newMat.name = M.name+"_"+(getfilenamefile files[i])
NewMat.diffusemap = Bitmaptexture fileName:files[i] apply:true
showTextureMap NewMat on
S = sphere pos:[i*2.2,0,0] radius:1 segments:8
S.material
Hope this answered your question