PDA

View Full Version : create 100 shader with maxscript


herrnilsson
06-30-2010, 04:11 PM
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?

Floating_Inkpot
07-01-2010, 02:06 PM
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

CGTalk Moderation
07-01-2010, 02:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.