PDA

View Full Version : The Embed-Mat Plugin for ZBrush 3


Svengali
10-28-07, 12:05 AM
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.

embed your choice2.jpg

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.

material select14.jpg

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

WailingMonkey
10-28-07, 12:45 AM
awesome job, Svengali! You (and marcus_civis) continue to make
Zbrush even better. :)

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

http://img90.imageshack.us/img90/2690/embedmatrq1.jpg


WailingMonkey

Trybal
10-28-07, 12:46 AM
Awesome. Thank you very much. :) :tu:

piz
10-28-07, 02:02 AM
Svengali, Thanks for your very useful tool! :tu: :tu: :tu: :tu: :tu:

Plakkie
10-28-07, 04:20 AM
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. :tu: :tu: :tu:

TVeyes
10-29-07, 06:14 PM
Nicely presented and effective workflow implementation. I like this update :tu:

Thank you Svengali.

marcus_civis
11-06-07, 05:31 AM
A very useful utility Sven, and thanks for the clear explanation on materials. Sometime I'll show you how to create a wiki account. ;)

xhlin
01-23-08, 04:35 PM
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!

Svengali
01-23-08, 10:14 PM
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

xhlin
01-24-08, 02:46 AM
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 ;)
guess it will work fine now!
thanks for your work!

EddyLoonstijn
01-24-08, 09:47 AM
Hi Svengali,

You've been doing a lot of zscripting, and with a very intersting result!:tu:

Greetings, EddyL

N8
02-02-08, 10:18 AM
this is a great tool! thx for doing this!!

Kravit
03-27-09, 05:32 PM
Anyone else having trouble getting this to work. Im getting error
Zscript Note : Interface item does not have special modifiers

Svengali
03-27-09, 09:24 PM
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.

SNARK
03-28-09, 11:39 AM
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.~

gallant77
12-03-09, 03:56 AM
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?

Svengali
12-17-09, 02:54 AM
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

marcus_civis
12-17-09, 03:16 AM
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.

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.

Svengali
12-17-09, 04:02 AM
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

marcus_civis
12-17-09, 06:06 AM
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.

Svengali
12-17-09, 07:52 AM
Marcus,

Here's the problem. Let's say you want to create a NEW tool-texture based on the polypainting (and material) assigned to the current subtool.

Under Tool>Texture Map, you click the New Txtr button... a new BLANK tool-texture is created and applied to the subtool. You then press the New From PolyPaint button which transfers polypaint and material onto the tool-texture... and you can see it in the tool-texture icon.

Next, you might momentarily click on the new Tool-Texture's icon and select Texture-Off, maybe because you want to look at the polypainting again or you might select another, existing texture.

By doing so, the newly created tool-texture DISAPPEARS, for good! Unless you've remembered to clone it BEFORE selecting the Texture-Off button, to save it as an ACTUAL Texture.

I'm just emphasizing the point that, UNTIL you actually create a cloned-copy of a tool-texture, the tool-texture you see is just 'dust in the wind'. This can be especially frustrating if you are used to thinking (in the old ZB 3.1 mindset) that by simply creating the texture from polypaint, your job is done.

This new, r3 twist with textures was the whole reason I recommended modifying the left-shelf layout to include the Tool-Texture Icon and the Clone Txtr button << HERE >> (http://www.zbrushcentral.com/showthread.php?t=78549) . Any ZBrush artist working with multiple subtool-textures NEEDS to always be able to see the current Tool-Texture along with the current Texture.

Thinking about it, I wonder that Pixologic didn't ship r3 with the Tool-texture icon already on the left shelf along with the current Texture Icon and all the other current icons as part of the default setup?

Sven

marcus_civis
12-17-09, 07:58 AM
Sven,

These are good points and I shall pass them on to the development team.

Thanks,