ZBrushCentral

MATSAVER: Custom Materials Saver

About MatSaver

Building on the tip TVeyes posted a few days ago, here is a ZScript quickie that lets you save your custom materials for later reloading. The handy thing about it is that you save them all in one process.

Here’s how it works.

Whenever you save a DOCUMENT, it stores Pixol information including color, material and Z-depth. If a pixol uses custom materials, the DOCUMENT actually embeds the complete description of all those materials in the file. If you save your work as a DOCUMENT, you preserve the custom materials, but you also save all the other info which can end up being a big file.

What MatSaver.txt does is first check the materials actually being used courtesy of the nifty little routine TVeyes gave us. Then it creates a table of spheres consisting of only those materials that were found.

![stored materials.jpg|570x160](upload://9MBVn8BFwZEpoEI7l212IlKZ9t8.jpeg)

After MatSaver is finished, the sphere table index with labels can be SAVED AS a DOCUMENT.

Later, in another work session you can restore all the custom materials IN THEIR CORRECT SLOTS at once, by simply reloading the DOCUMENT. Then load your models and textures and proceed with modeling where you left off.

One Warning:
Before creating the table, the canvas is resized and erased, so whatever is on the canvas when you run MatSaver WILL BE LOST. Therefore, only run MatSaver after everything else is saved and you are ready to save your custom materials. When you run MatSaver, you are warned about the loss and must press YES to proceed.

Please, PLEASE EXPERIMENT WITH IT A FEW TIMES BEFORE YOU USE IT ON ANY SERIOUS PROJECT!

Feel free to modify the script and post improvements - I did this version quick and dirty.

To use, unzip matsaver.txt and 76materials.jpg into the same folder.

Sven

ps. Aminuts: I thought you might find this interesting, too. :smiley:

Hi Sven,
good utility…for sharing too.

cameyo

woooohooooo I think I love you!!!Yes!! Yes!! I am gonna love this! Thank you!!:smiley: :smiley:

ps. Expect an email soon…need to gather up some pics and thoughts first…hhahaha and some time…yikes!

Hi Sven,
This is really neat and thanks for sharing the code!!!:D:D:D

[That FileNameAsk problem is annoying!!..]

Marcus

Thanks all for the feedback! If and when anyone gets a chance to actually use MatSaver, please post a quick note on how it is being used (helpful for me and for anyone else who reads this post.)

One thing I really like about the new forum format are those related links that are added at the bottom of each thread, links whose selection depends on keywords that appeared in their titles - this argues strongly for carefully choosing titles to your own posts (even responses?).

At the bottom of this thread I discovered another thread from January on the topic of custom materials and the discussion by Matthew of ALL the details, procedures and pitfalls involved in saving and loading your custom materials… it’s worth a read and shows where the idea for MatSaver got its start and why TVeyes tip finally made it do-able.

If I get time later, I might try rewriting MatSaver to make it a little more user friendly… :rolleyes:

Sven

Pretty slick Sven, I especially like the elegant way you create the material table jpeg image. One enhancement I could think of would be to also save the light setup used from the Parent document, it could be saved with the same name that you choose for the document name. You could also include a file “Open” function that would open the saved material document along with the light setup.

Anyhoo, great contribution!

Hi Digits,

Actually, I just did a test concerning custom lighting and custom render settings and guess what, those get saved too with the DOCUMENT.

So, whatever the state of your environment at the moment you run MatSaver, that’s what you restore back to, when you reload the DOCUMENT!

This tells me I need to think some more about the MatSaver interface options and parameters, but at the moment - I’ll call it a surprise bonus. :slight_smile:

Sven

Yeah, hehe I realized that right after I posted, duh! :roll_eyes: Makes the script even more useful killing two birds with one stone:+1: