Forum: Poser - OFFICIAL


Subject: Nodes for Dummies

RobynsVeil opened this issue on Jan 24, 2009 · 490 posts


bagginsbill posted Mon, 02 July 2012 at 6:44 AM

I have been using matmatic extensively for the hundreds of materials I include in the products I do with DreamlandModels. I made a couple improvements I will publish.

One of the design choices I made early on regarding material collections was based on the premise that I would be doing the same collection over and over (a figure) and so it was important to establish automatic rules so that in the script I only had to set a couple zones.

For example, I could assign to both fingernails and toenails by saying

c = Collection()

c.nails = Glossy(RED * .25) # assuming Glossy is a function that creates a shader

But this turned out to make life more difficult when one had to deal with a different prop or figure on a daily basis. In that situation, setting up rules for implied material assigments turns out to be more trouble than it's worth.

So I added a new method to matmatic's Collection object - apply. No rules or smarts, you simply give it a material and a list of zones to apply to. If you forget one, it will do nothing to help you, but it is easy enough to make your lists once and use them again.

So now my approach is like this:

c = Collection()

c.apply(Glossy(Red * .25), "fingernails", "toenails")

Another decision I made long ago that is not so great is that the name of your matmatic script appears in the name of the materials it generates. I made a new option to stop that - if the name in the outputs list begins with the equals sign (=) the script name is not added. It will just use the name as is.

Also, I need to create and use subfolders, and these are allowed in the output name as well. So for example, if I want to put a Blue.mt5 file in a subfolder called Paints, I can say:

outputs += [ "Paints/=Blue", someMaterial ]

In the shaders I use for Furniture Set One, I have four wood zones I need to populate over and over again.

woodZones = ["Panels", "DrawerFaces", "Top", "Feet"]

And I often make lists of colors, like this:

paintColors = [

  (IColor(.4, .05, .05), "Dark Red"),

  (IColor(.5, .7, .6), "Some Green"),

]

And I have a loop like this to make mc6 files for the wood zones as well as a single material file, one each per color:

for clr,name in paintColors:

  material = Glossy(color=clr)

  fileName = "Paint %s" % name

  outputs += [ "Singles/=%s" % fileName, material ]

  outputs += [ "Wood/%s" % fileName, Collection().apply(material, *woodZones) ]

Another workflow thing I improved has made a huge difference. I do not write a material file if it isn't different.

This doesn't sound like much but it really is. Matmatic now generates the material and if the file exists already, it examines the contents to see if what it just generated is the same or different. If it is the same, it does not write over the file. The reason this matters is that the file's modification time stamp remains the same.

By itself that sounds like a "who care's" thing, but for the fact that I also have another script that automatically generates thumbnails by doing renders of every material. When a material and its thumbnail both exist already, it examines the modification time stamps to see which is newer. If the PNG file is newer than the material, it assumes (usually correctly) that the thumbnail is up to date and can be skipped.

So now I have a script that generates 200 to 300 materials. When I make a tiny change - perhaps a color change to one paint - only a few are affected. Then the thumbnail generator runs and only a few renders are done.

These changes have saved me many hours.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)