ZBrushCentral

The Embed-Mat Plugin for ZBrush 3

XYZPaintSplash.jpg

The Embed-Mat Plugin for ZBrush 3

The Embed-Mat Plugin presents a simple way to assign or EMBED materials to your models, subtools and texture maps. To put the Embed-Mat Plugin to best use, you should first understand how materials are handled in ZBrush. Here’s a quick and dirty review of the important Material issues.

Models and Texture Maps

Models are made up of polygons where each individual polygon can have one color and one material assigned to it. In a similar fashion, Texture Maps are made up of pixels where each individual pixel can have one color and one material assigned to it.

But what is really being assigned to the polygon or the pixel is just an index number which then references a table with an entry describing the material assigned to it. The render engine looks at each polygon or pixel and, based on the number it finds there, renders the appropriate material from the library onto your screen.

By default, when you create a new model, all its polygons are automatically assigned material index zero. A new texture map will also have material index zero assigned to each of its pixels.

Material Index Zero

Material index zero, named Flat Color, is both unique and a little weird (sometimes difficult to understand).

  1. The Flat Color located at material index zero is the only one that cannot be replaced by a custom material. It will always be Flat Color.

  2. When you pick any other material from the material table, material index zero temporarily ASSUMES the identity of the chosen material, even though the embedded index number for the model polygons or texture map pixels remains zero.

  3. Each time you click on another material, those polygons or pixels embedded with material index zero ASSUME that new material appearance.

In other words, Material Index zero acts like a chamelion and is ALWAYS DYNAMIC OR “LIVE”. (note that two of the buttons on the Embed-Mat menu will cause the model, subtool or the texture map to blink if material index 0 is still assigned to it!)

If you want to permanently assign any other material (above index zero) to a model or texture map you need to EMBED the new material’s index number in the model polygons or texture map pixels.

Normally, to embed a model you first select a material from the table, then press the Draw:M button and finally, press the Fill Object button in the Color Menu.

To embed a texture map by hand is a little more complicated. One quick way is to select Plane3d, convert it to a PolyMesh3d model and display it on canvas in edit mode. Choose the material (you want to embed in the texture map) and embed it in the PolyMesh3d (as explained above). Next, choose the texture map you want to embed so it is displayed on the Plane3d. Click the Draw:M button. And finally, click the Tool>Texture>Col>txr button.

After embedding your model or your texture map with a new material, they will no longer change material appearance when you choose another material.

The Embed-Mat plugin

This plugin makes the embedding process for models and texture maps simple. As a bonus, it makes assigning different materials to different, individual subtools simple as well. The Embed-Mat menu (shown above) offers different options depending on whether the current model has multiple subtools and on whether you have a texture map selected or not. It’s easy to use but some of the extra features need a bit more explaining.

The above menu information is divided into three parts: The dark part at the top tells you what material you’ve chosen. Under that are stats describing which model you’ve chosen and the name of the texture map (if one has been selected). Finally is a set of buttons whose functionality is explained by their labeling.

One of the sub-menus, Embed SubTools - Your Choice, has special buttons as explained below.

[attach=73889]embed your choice2.jpg[/attach]

First you should know that when you install the Embed-Mat plugin you will also be asked to install five custom materials into the ZStartup/Materials folder. The five new materials are named “Custom1” through “Custom5”.

When you choose this menu, you are stepped through all of the subtools, one by one, and offered a choice of what material to embed in each. As a material is chosen, you will see the subtool updated with that material. So, here is what the buttons do:

The Embed Button - this will embed the material named at the top of the menu in white text.
The Skip Button - lets you bypass the current subtool without assigning a material.
The Exit Button - lets you abort the subtool material menu and return to the main Embed-Mat menu.
The five Color Buttons - Each of these buttons represents one of the five custom material slots. The index numbers you see listed on the buttons might be different from what you see here but that doesn’t matter. Each material is unique and, once assigned, any other custom material can be loaded into that index slot and will display on your model’s subtool.

(NOTE: one additional comment on the custom materials: If you have your own favorite materials that you’d like to use for embedding, you can remove the original custom materials, then name and load your own material files as custom01.zmt through custom05.zmt into the ZStartup/Materials folder.)

You can see that the demo-soldier’s subtools have all been assigned different custom materials through this sub-menu.

Installing Embed-Mat

The Embed-Mat.zip file contains six files. Place them in the following folders.

Place this file in the ZStartup/ZPlugs folder
Embed-Mat.zsc

Place these five files in the ZStartup/Materials folder

  1. custom01.ZMT
  2. custom02.ZMT
  3. custom03.ZMT
  4. custom04.ZMT
  5. custom05.ZMT

When you restart ZBrush, a new button called Embed-Mat will appear in the ZPlugin menu under the Svengali group. Drag this button to your custom interface and update the interface.

The ZBrush Materials Palette now shows the five new custom materials added for use by Embed-Mat. These five custom material slots can be used any time you need to load some customized material file into an unused slot.

[attach=73890]material select14.jpg[/attach]

I strongly suggest that if you decide to use the Embed-Mat plugin you first experiment with the demo soldier and its subtools to see how it works. If anyone has any questions or problems, please post in this thread. Once again I’d like to thank Marcus_civis for his help in testing and debugging this plugin.

Sven

Attachments

embed your choice2.jpg

material select14.jpg

awesome job, Svengali! You (and marcus_civis) continue to make
Zbrush even better. :slight_smile:

Thank you for that. Here’s a rather garrish soldier-boy just for giggles:

WailingMonkey

Awesome. Thank you very much. :slight_smile: :+1:

Svengali, Thanks for your very useful tool! :+1: :+1: :+1: :+1: :+1:

If I understand this correctly this could solve many problems for me. I’m gonna try it out. Thanks Svengali for making yet another workflow improving Plugin!! Also thanks for explaining the exact workings of Zbrush to us. :+1: :+1: :+1:

Nicely presented and effective workflow implementation. I like this update :+1:

Thank you Svengali.

A very useful utility Sven, and thanks for the clear explanation on materials. Sometime I’ll show you how to create a wiki account. :wink:

hey! your plug is exactly what i’m looking for but when i place the custom.zmt files in the ZStartup/Materials folder, zbrush freezes and can’t load the materials?
is there a trick?

help!

xhlin,

No trick, they should simply load when you start ZBrush if you put the custom files in the ZStartup/Materials folder.

I suppose you might have a problem if you’ve loaded the Materials folder up with a bunch of other custom materials as there is a limit to how many custom materials you can auto-load on startup… in that case clear out a few of your other custom materials and try loading my custom materials again.

If you still can’t get them to work, try this work around:

(note that there is nothing unique about my five custom materials…)

Replace my custom materials - by simply loading five of your own custom materials. Save them into the Materials folder by overwriting mine, naming them Custom01.zmt, Custom02.zmt, etc.

You should then be able to startup ZBrush without a problem.

Sven

S, thank you for your hacking skills!
i tried to import your materials directly then i got notified i was running v. 3.0 NOT 3.1 :wink:
guess it will work fine now!
thanks for your work!

Hi Svengali,

You’ve been doing a lot of zscripting, and with a very intersting result!:+1:

Greetings, EddyL

this is a great tool! thx for doing this!!

Anyone else having trouble getting this to work. Im getting error
Zscript Note : Interface item does not have special modifiers

Kravit,

Please give me a little more to go on and I might be able to solve your problem… are you using the Mac version of Zbrush? or PC version? When do you get the message (what causes it to appear) and could you do a screen grab of the message itself? What is the model like that is giving you the problem and does the same error also happen on every other model you tried using Embed-Mat plugin with?

Sven

PS The other alternative is to use Subtool Master which duplicates (pretty much) what Embat-Mat does plus a whole lot of other great Subtool stuff.

Hi, Svengali.

I just stumbled upon this utility and I like it very much. This is such a great community. People like you work on your ‘Off Hours’ to make ZBrush better and we all benefit from your selfless sharing.

NOTE TO ZBRUSHERS: Make sure all tools and subtools are ‘PolyMeshes’ or the functions will not perform.

Thanks!

~S.~

This is very convenient in applying different materials to different subtools but does this plugin able to allow me to apply different texture into different subtools?

gallant77

Remember this plugin was originally designed for ZB 3.1, which did not allow different textures for different subtools…

So, no it doesn’t support that. Sorry.

In fact, I’ve experimented a bit with ZB 3.5r3 trying to embedding materials in texture maps and have not been able to do so without affecting the rgb values already stored in the map. The Tool>Texture>Col>txr button from ZB 3.1 seems to have gone missing and I don’t find any equivalent functionality in the r3 release. Perhaps it will return in ZB 4?

Svengali

This is now Tool>Texture Map>New from Polypaint. UVs need to be set up, and the size of map set in the Tool>UV Map>UV Map Size slider.

Hi Marcus,

Yes, but the problem is you can’t independently update rgb or material on the Tool-Texture, it’s both or nothing (and the DRAW settings don’t matter (Mrgb, rgb or M). At least that’s how it seems to work for me.

I think the work around is to copy the rgb of the map onto the subtool polypaint, then imbed the material in the subtool using fill object with only M set, then copying BOTH polypainting and embedded material back onto the texture… but it’s a different, hinkier process from 3.1, creating several unnecessary steps.

Also worth noting is that IMMEDIATELY FOLLOWING THE CREATION OF THE NEW TOOL-TEXTURE YOU MUST CLONE IT TOO, OR THE NEW TOOL-TEXTURE WILL BE LOST. Just because the new rgb or material appears to have been transferred to the tool-texture, does not mean that an independent texture map has been created or updated.

At least that’s how it seems to work for me.

Sven

Sven,

I think that’s how it works at the moment. Any new tool texture map created will replace the previous map, so if copies are required they need to be cloned. An alternative method would be to save versions of the ztool, as texture maps are saved with the tool.