MaxScript – Standard Material Ops

This is a short code snippet that shows how to create and set material instance for an object using maxscript. this can be wrapped into a function or struct-method. i thought i would post it here so that i can get to this later when or if i will ever need this.

--Making dummy object
--creating material instance
b.material = Standardmaterial()
--assigning BitmapTextures to specific channels
b.material.diffuseMap = Bitmaptexture()
b.material.specularMap = Bitmaptexture()
b.material.bumpmap = Bitmaptexture()
--specify files for bitmaps
b.material.diffuseMap.filename = @"D:\Diffuse_D.bmp"
b.material.specularMap.filename  = @"D:\Specular_M.bmp"
b.material.bumpmap.filename = @"D:\Normal_N.bmp"
--let material be visible in viewport
b.material.showinViewport = True

4 responses to “MaxScript – Standard Material Ops

  1. You can also use keyword parameters when creating the material (same applies to any object, modifier etc.):

    b = Box()
    b.material = StandardMaterial showInViewport: on \
    diffuseMap: (BitmapTexture filename: @”D:\Diffuse_D.bmp”) \
    specularMap: (BitmapTexture filename: @”D:\Specular_M.bmp”) \
    bumpMap: (BitmapTexture filename: @”D:\Normal_N.bmp”)

  2. Better start using it, then 🙂 It’s not just a different syntax, it’s a different approach – instead of creating object, accessing its properties and updating them one by one, you can do all the work when the object is created, before it’s added to the scene. Doesn’t make a noticeable difference here but it pays off in the long run when you meet more involved challenges.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s