ZBrushCentral

Exporting normal maps from ZBrush

I got fascinated by the “Lighting Flat Objects” tutorial demonstrated by Olivier Renouard.

It should be theoretically possible to paint a bush / tree in ZBrush and then use that as a flat normal-mapped billboard object in a 3D hardware accelerated application (game), right?

So, how would one go about exporting the orientation information from a ZBrush document as a normal map?

Hehe Skaven
You have found these very interesant Olivier’s links at this Post ? :slight_smile:
That you ask is the concept of Zbrush itself ! The “pixol” :slight_smile:
Each pixol has your informmation wished and more ! :slight_smile:
Ask Pix the trick for convert the pixol’s matrix for your flat normal map billboard tree :slight_smile:
Pilou

well for normal mapping to work correctly as I’ve understood it with olivers thread and the spiraloid thread, it’s dependent on micropoly rendering engines such as Renderman or Renderman compliant renderers. If you want to take 2d images from Zbrush and used them as 3D objects but with no depth that’s simple. Paint what you want, export as a photoshop object, open in photoshop, delete background, save as a PSD, insert the psd into the tranparancy channel, apply to the object. Now that is the work flow from Zbrush to Cinema, I’m going to read that thread of olivers in regards to flat objects when I get a chance later…there is a methodology of doing this in Cinema as well…What program are you using as your poly/animation/renderer?

David

Frenchy Pilou;
<BLOCKQUOTE>quote:</font><HR>You have found these very interesant Olivier’s links at this Post?<HR></BLOCKQUOTE>

Yes, that’s what got me into it. Very interesting topics at Drone.org!

DavidT;
<BLOCKQUOTE>quote:</font><HR>What program are you using as your poly/animation/renderer?<HR></BLOCKQUOTE>

Not really a program, but a game engine. Any DirectX or OpenGL game engine that uses per pixel shading, really. One of the upcoming games that uses this technology is Doom III. The characters have relatively low polygon counts, but they have smaller surface details (muscles, facial features, etc) created with normal mapping. This means that as the light changes direction, they are correctly shaded, just like the billboard tree in the webpage I posted in the first thread.

This is basically what I’m after:

[img]http://www2.zbrushcentral.com/uploaded_from_zbc/200306/user_image-1054704036mim.jpg[/img]

Original ZBrush image.

[img]http://www2.zbrushcentral.com/uploaded_from_zbc/200306/user_image-1054704198wcg.jpg[/img]

Flat Color image. This should be used as the color map of the intended billboard.

[img]http://www2.zbrushcentral.com/uploaded_from_zbc/200306/user_image-1054704288pbx.jpg[/img]

This is the Alpha map, that determines the transparency of the billboard.

And now for the real meat and potatoes I’m after:

The normal map. This is not a “real” normal map (I think). I created it by using a material that reflects the “Spectrum” texture at 100%, with full ambient and zero Diffuse / Specular.

Normal maps sort of look like this. I’m not familiar with the exact maths and values, but RGB values are used to represent the orientation of each pixel. The stronger the color, the more the pixel is oriented to the direction indicated the color, while pixels oriented towards the surface normal (=you) are grey. This information is used when the object is shaded according to a light source in the game.

Now, I guess the real question is: is, what I just did, actually the right way to produce normal maps from ZBrush, or not? And if not, how do I do it? :slight_smile:

Hi Skaven
Your meats and patatoes seems very appetizing :slight_smile:
Can you enlighting me for a confused little problem ?
When your 3Dform is on “side view”, it’s the same flat normal-mapped billboard calculated first (front view)
who works or you must calculate a new flat map ?
Pilou not very familiar with this sort of new things :slight_smile:

Yes - the polygon basically looks flat when viewed from the side. Only the texture is shaded according to the normal map. In Doom III, you may notice that while the characters’ surfaces have a lot of small shaded details, none of these actually show on the outline of the character, because the characters still only consist of a small number of polygons. The details are only in the shading of the texture. It’s just like bump mapping: the surface looks rough, but it’s just an illusion. :slight_smile:

Take a look at this page. It explains it pretty well. It also educated me, making it clear that my assumption (using the Spectrum gradient as a refletion map) was wrong - it is not the correct way to produce a normal map from ZBrush.

Sooo… how do I do it? The page suggests I should do this in three steps. First, the image should be lit from right (horizontal) and a grayscale (#1) rendered from that. Then, it should be lit from above (vertical), and another greyscale (#2) rendered from that. And finally, it should be MRGBZ grabbed, and the Alpha (depth) map exported into a third greyscale image (#3).

After this, these three greyscale images should be combined in Photoshop so that #1 goes into the Red channel, #2 goes into the Green channel, and #3 goes in the Blue channel.

Is that how it’s done?

Could someone at Pixologic create a shader / material that does this in one step? :smiley: ZBrush could become the perfect tool for creating normal mapped textures for games.

Hi Skaven
Ok, I understand a little more :slight_smile:
The paradox is the map that you want was used (on matrix form)
for calculate the Zbrush image in best render(light shadows reflex…) :slight_smile:
It’s one more time the concept of the “Pixol” :)(slide one time)
The recovery at the moment of the process should not be more difficult
but you must access to the process :smiley:
Pilou

Yeah, exactly. The information is there, we just need a way to get it out for other applications. :smiley:

Aurick, Pixolator, do you have anything to comment on this?

Instead of using a material & lighting setup to create the RGB/normal map info, it could be easier(and perhaps more precise) to use a zscript.

I’m thinking of the [PixolPick,…] command which can retrieve the normals of a single Pixol. I’m sure you could calculate the RGB value from the X and Y normals (their range is -1 to 1). After retrieving and calculating all the data you could easily paint the color on the canvas,MRGBZgrab and export. I might try my hand at making such a script this weekend, what do you think?

Why yes, that would be cool if you have the time and it’s not too much trouble.

But perhaps there is an even better way - maybe we should wait for a comment from Pixologic?

The steps that you describe above don’t create a real normal map. They just create a pretty picture.

As I understand things, the current way to obtain a normal map using ZBrush in the workflow is as follows:

  1. Create your LowFrequency mesh and save it.
  2. Use the LowFrequency mesh as a basis for creating the MediumFrequency mesh. Save that.
  3. Export both and use a normal-mapping program to create the normal map. This map represents the difference between the two meshes.
  4. Apply the normal map in a rendering engine that is capable of supporting it.

Cinema 4D does not currently fall into that category, as its displacement mapping is still the most primitive form of it (vertex displacement). Other programs also employ vertex displacement, but add algorithms to increase the poly count at render time. Finally, the most advanced displacement method (which is employed by Renderman and some game engines, to name a couple) uses micro-poly displacement. This process incorporates the displacement into the rendering itself, and displaces pixels rather than points. It is the most successful form of displacement, and requires the lowest system resources.

I cannot at this time reveal what the next version of ZBrush will do beyond what has already been stated by Pixolator. What I can say is that while the current version of ZBrush works well with the steps described above, the next version has features that make it very easy to create incredibly detailed MediumFrequency meshes.

Hope that helps!

<BLOCKQUOTE>quote:</font><HR>1) Create your LowFrequency mesh and save it.
2) Use the LowFrequency mesh as a basis for creating the MediumFrequency mesh. Save that. (…) <HR></BLOCKQUOTE>

Thank you for your reply, Aurick! I was, however, just looking for a way to export pixol information from the canvas into a normal map. No high / low detail meshes needed.

ZBrush could be a great tool for authoring normal mapped (flat) terrain / level textures for games, since it’s really easy to make the textures tileable (how would you do that in a 3D modeller?), and it’s possible to paint massive amounts of detail into them without having to bother with jerkiness coming from high polycounts.

All we need is a way to extract the information that is embedded into the pixols, into a normal map.

Well stated Matthew.

I suspect from everything I have seen that the next version of ZBrush will have some sort of extraction capability (as Matthew has already stated) designed specifically to do for low-poly models what normal mapping does now in other 3d apps. Whether this capability is indeed true normal mapping remains to be seen. I am excited either way. :slight_smile:

Exactly Skaven, I read the “Creating Normal Maps with Cinema 4D” article a while ago and thought it would be great to be able to do it through Zbrush. Considering the amount of detail you can create through merely Zsub/Zadd’ing it would seem the perfect candidate for normal map making(and of course textures in general).

Anyway I completed the Zscript, but I am sorry… I forgot how slow editing an image pixol by pixol is. The script works and I think it adheres to the guidelines of what the color values should be, as stated in the above mentioned article. But, a big but, it is very slow, a 256x256 image takes about 2:13 minutes, a 512x512 took about 13 minutes, both on a P4 2Ghz :). Apart from that it seems to work ok, although some strange problem occurs when the normals are -1/1 or very close to that.

A couple of tests:

The script is very basic, just a single button but if anyone thinks it is worth anything I might add stuff like a user Zvalue (right now it is fully blue(255) as I gathered it was supposed to be), a Min/Max range for the Red and Green (no idea what it could be used for :)) and a batch processing for taking multiple .zbr’s and letting them normal map themselves while you eat dinner, watch a movie and have that laser surgery on your eye you allways wanted :wink:

I had a quick try at doing normal maps via materials and lighting, but quickly realised it would be far too much trial and error, for me at least. But it should in theory be very possible that Pixologic could make a special Material that showed normal mapping colors and allowed us to MRGBZgrab it.

And here is the script:
PixolNormalMapper.txt

I recommend you resize the canvas to 256x256 or smaller when testing it and also hit the Flat Renderer before clicking the button, so you can see what is going on(in this day and age 2 minutes and 13 seconds is faaar to long :D) If you are just jumping into this thread remember you need some pixols in there that the script can compute.

Do you think to obtain a thread as big than the last PixoRock Challenge ? :wink:
Go ahead Skaven and Tveyes :cool:
I have the presentiment that is a simple regulating (as curves Graph) for find this sort of map :slight_smile:
Pilou

Hi :slight_smile:

Skaven252: Good question!

Adding to the method described by aurick… It is possible to produce normal-maps of a ZBrush document by using a customized material or by a ZScript ( such as the one that was created & posted by TVeyes, thanks TVeyes :)) .

I’ll post a NormalMapMat.zmt material shortly :slight_smile:
-Pixolator

Wow, look at all the activity taking place while I’m asleep! :slight_smile: (time zone difference)

I tried your script, TVeyes, and it indeed does work! And yes, it indeed is very slow (still processing a 512x512 canvas while I’m writing this). I noticed some problems with pixols that are nearly -1 / 1 in value, like you said (I wonder what causes them? Should be relatively easily avoided by Blurring those areas slightly before processing).

And wow, Pixolator! With a shader like that, ZBrush will allow you to make normal mapped, tiling game textures like never seen before! :eek: Looking forward to laying my hands on that. Many thanks to the Pixologic team for creating such a unique creative tool as ZBrush.

Here are some points to consider when making the textures (based on a gut feeling, please verify):

:b2: You should not use a Color Bump material if you intend to use the texture in a game and want the ZBrush document reflect what the final result will look like. Color Bump does not translate to the normal map if it is created with a proprietary shader material.

:b2: While most standard game engines don’t have as elaborate material settings as ZBrush, there are some things you can do, such as Specular / EnvMap masking. The procedure to create the masks for these (I think) is to replace the special materials with a white Flat Color (one at a time) and replace the other materials with black Flat Color. If you want a smooth, blurred Specular / Env map (like a smooth transition of Specular shininess in a material), you’ll have to do some smudging after merging the layer.

He he Skaven
Your dream becomes reality :cool:
Just when I maybe find something Pix is arriving :smiley:
Have future good "A"normal-maping :smiley:
Pilou

Hi :slight_smile:
Skaven252: Here is a material which is similar to the one that you have already described in your post. This material will allow you to produce the same maps as described in the link that you have posted…

About the NormalRGBMat material
The material was created by assigning a RGB-gradient texture as a material reflection-map. In order for this to work properly, the reflection is assigned to a reflection-specific shader and not the standard reflection-shader (in order to extract the direct-normals, not the reflection-normals).

To use this material, simply load it into your ZBrush document. You may load it directly into a material index which is used in your image or, load it into a an unused material index and then apply the material to the canvas. The only item that you do need to set is to reduce the ambient value in the LIGHT palette to zero.

When you use this material, your document will render (in Preview & in Best render mode) to look as a NormalRGB map (shown in the bottom of the above image). You may then export the document directly or use the MRGBZGrabber to grab the NormalMap as well as the Height/Bump Map (which will be available in the Alpha palette). If needed, the Height map can replace the blue (z-normal) channel.


Click icon to download the NormalRGBMat

I do recommend to any member who is using (or planning to use) NormalMaps in their projects, to test the above material and post your finding in this thread. This will allow us to tweak and if required, add NormalMap-related feature to the next ZBrush release.

Hope this helps :slight_smile:
-Pixolator

WOW! thanks Pixolator!

This new material looks realy neat!!!

I dont know If I am useing this in the proper way, but It looks realy neat!!

Thanks again for the new neat material :slight_smile:

Here is a what I did with it :slight_smile: makes the wrinkles realy stand out