Issuu on Google+

The Alpha Displacement Exporter for ZBrush

Abstract: The Alpha Displacement Exporter (or ADE for short) is a new plugin for ZBrush that allows alpha (grayscale) maps to be more easily exported for use as displacement or normal maps in other programs. The ADE allows definition of exactly how alpha data is stored within TIFF files. It also allows adjustments on the alpha data, to minimize the amount of adjustment that needs to be done in the target program. Š 2005 Pixologic, Inc. All rights reserved. Pixologic and the Pixologic logo, and ZBrush and the ZBrush logo, are registered trademarks of Pixologic, Inc. All other trademarks are the property of their respective owners.

1


Table of Contents 1.

INTRODUCTION ....................................................................................................................................... 3 1.1. ALPHAS, DISPLACEMENTS, AND NORMAL MAPS ................................................................................. 3 1.2. THE PURPOSE OF THE ALPHA DISPLACEMENT EXPORTER ................................................................... 3 1.2.1. Presets............................................................................................................................................ 3 1.2.2. Quick Codes................................................................................................................................... 3

2.

INSTALLATION OF THE ADE .............................................................................................................. 4

3.

ISSUES IN EXPORTING ALPHAS FOR DISPLACEMENT............................................................ 4

4.

THE TIFF FILE FORMAT....................................................................................................................... 5 4.1. 4.2. 4.3.

5.

CHANNELS .............................................................................................................................................. 5 CHANNEL RESOLUTION ......................................................................................................................... 5 DISTRIBUTING INFORMATION ACROSS CHANNELS .............................................................................. 6

ADE INTERFACE ...................................................................................................................................... 7 5.1. STARTING THE ADE............................................................................................................................... 7 5.2. ADE INTERFACE LAYOUT ..................................................................................................................... 7 5.3. CONFIGURATION O PTIONS ..................................................................................................................... 9 5.3.1. Configuration Options Layout.................................................................................................... 10 5.3.2. File Options ................................................................................................................................. 10 5.3.3. Per Channel Options................................................................................................................... 11

6.

PREDEFINED CONFIGURATIONS.................................................................................................... 12

7.

EXPORTING ALPHAS ........................................................................................................................... 13

8.

NORMAL MAPS....................................................................................................................................... 13 8.1. 8.2.

NORMAL MAP CONFIGURATION OPTIONS .......................................................................................... 13 NORMAL MAP INTENSITY ADJUSTMENT SLIDER ................................................................................ 14

2


1. Introduction 1.1. Alphas, Displacements, and Normal Maps An alpha (or alpha map, or alpha image, depending on your preference) is a grayscale image wherein different levels of bright or dark at a point are interpreted as intensity values to be applied to something else. For example, one of the earliest uses of alphas in graphics was to define how transparent an image was at its different points; accompanying the image was an alpha of the same size as the image, and the intensity of the alpha at a point determined how transparent the image would be at that point. A common use for alphas in 3D graphics is as displacement maps. In this use, an alpha is applied to a 3D surface, and points on that surface can be raised or lowered depending on the value of the alpha intensity at that point. Rather than applying a displacement map to an object, it may be possible to use a normal map, which can give the appearance of displacements, and offers certain advantages if actual changes in geometry are not needed. A normal map can be calculated from a displacement map, which is to say, from an alpha. Detailed descriptions of how normal maps work are available in graphics books or in many places on the web.

1.2. The Purpose of the Alpha Displacement Exporter This concept of alpha maps for displacement or normal mapping is simple, but there are various technical details that need to be handled correctly when transferring alphas between different packages. Taking care of all of these details by hand is time-consuming and prone to error. ZBrush’s Alpha Displacement Exporter (ADE) allows you to set just once the options you need to correctly export alphas to your favorite program. ZBrush will remember and apply those options from that point on. Before getting into the technical details of transferring alpha displacements between applications, there are two features of the ADE that may allow you to use it with little or no configuration on your part. These are mentioned immediately below.

1.2.1. Presets The ADE ships with many predefined configurations, with names like D32 or PN16. One of these is likely to be appropriate for transferring a ZBrush alpha to your target program. If you are familiar with the import needs of your target program, and have some familiarity with TIFF file formats, you can go to section 6 for further explanation.

1.2.2. Quick Codes The ADE also provides a feature to enable you to quickly enter configurations developed by other users. Quick Codes are strings that define a full set of export configuration values. If none of the predefined ADE configurations are appropriate for your needs,

3


check ZBrushCentral1; you may find a quick code someone else has developed to transfer alphas to your application of interest. In that case, entering that quick code will give you the settings you need, and you will not need to worry about the other options in the ADE interface. To enter a quick code, see the description for the Quick Code interface item in 5.2.

2. Installation of the ADE Locate the main ZBrush program directory, and drag DispExporter.zsc and DispExporterData to the ZStartup/ZPlugs (or ZStartup\ZPlugs) directory in that directory2. The main ZBrush directory is typically /Applications/ZBrush (on Mac OS X®) or C:\Program Files\Pixologic\ZBrush (on Microsoft Windows®.) The ADE will be loaded the next time you start ZBrush.

3. Issues in Exporting Alphas for Displacement As mentioned before, displacement maps are simple in concept, but subject to various technical considerations when moving them between applications; this is what the ADE is designed to address. Below are the common challenges that can arise when moving a displacement map from one application to another: •

Mapping of alpha intensities to measurements in the target program’s world coordinate system. Displacement maps simply represent intensities, with no units attached. Should a value of white (the highest intensity) cause a displacement of a centimeter, an inch, a foot, or some other measurement? For that matter, should it cause a displacement into the surface, or out from it?

Displacement map grayscale resolution. Many alphas store 8 bits of data per pixel, meaning that they can represent only 256 distinct shades of gray, from black to white. ZBrush can store 16 bits of data per pixel in an alpha, which means alphas can have 65,536 distinct shades of gray. In practical terms, 16 bit displacement maps can produce much more realistic displacement surfaces when they are applied, particularly if the displacements are relatively large in the absolute coordinates of the global coordinate system where the map is being used. On the other hand, some programs may only be able to use 8 bit displacement maps, so provision must be made for converting a ZBrush 16 bit alpha into an 8 bit alpha for use by such programs.

1

File formats. Alphas are images, and so are moved between different programs using some sort of image file format. However, many types of standard image file formats do not offer a format that can easily deal with 16

www.zbrushcentral.com

2

DispExporter.zsc and DispExporterData will accompany this document, or will be available at www.zbrush.com.

4


bit alphas. The displacement exporter exports all of its files in TIFF format, which is a very flexible file format well suited to this type of application. However, the TIFF format is so flexible that different programs may expect alphas to be represented in different ways even within TIFF files, and so the displacement exporter allows you to define exactly how the data elements of the displacement alpha are stored into the TIFF file. See sections 4 and 5. If none of the ADE predefined configurations is suitable for your use, it’s still likely that most of the option settings you’ll need to make will be quite simple. Even better, other ZBrush users or your own technical support people may well define a necessary configuration, and then simply supply a Quick Code you can enter to get exactly the configuration you need for a specific task.

4. The TIFF File Format If you need to define options for your own exporter configuration, you’ll probably need to understand some things about the TIFF file format, since the ADE exports all of its displacement maps as TIFF files. If you are working with a predefined configuration, or can find a Quick Code that meets your needs, there’s no need to read this section.

4.1. Channels To begin, let’s look at the concept of “channels” within image data. A channel is just a set of data that all has to do with specifying the “same type” of information in the image, over the whole of the image. As an example, an image file format dealing only with grayscale images might have just one channel, and that channel would contain a grayscale intensity value for each point in the picture. On the other hand, most color image file formats define (at least) three channels; one contains the red intensity at each point in the picture, one contains the green intensity, and the third contains the blue intensity. So an image file generally contains one or more channels of information, and each channel contains values affecting some particular aspect of the appearance of the points in the image. Red, green, and blue channels are the most common, but channels can be used for other things also.

4.2. Channel Resolution Each channel has an associated resolution, which is a measure of how many gradations of intensity it can represent. The higher the resolution, the more accurately visual information can be stored. For example, many image file formats allow only 256 intensity levels for each color channel. Such a format can represent only 256 intensities of pure red (the blue and green channels will be 0 if a pure red is being shown), which is usually enough to produce decent onscreen images, but is far less than the range perceptible by the human eye. If you see phrases such as “channel width”, “bit depth”, “channel format”, and the like, chances are they are all referring to properties affecting channel resolution.

5


The resolution of a channel is determined by how much data is stored, for each image pixel, in that channel, and this is normally expressed by the number of bits (binary digits) stored at each point. Here’s a summary of how the number of bits corresponds to the resolution of a channel: Bits

Intensity Levels

8 bits 16 bits 32 bits

256 65,536 4,294,967,296

Other things being equal, the greater the resolution of the channel the better. 32 bit formats are usually stored in what is called a ‘floating-point’ format. In practical terms, this allows a further degree of accuracy under most circumstances, and with respect to the ADE, simplifies some aspects of exporting alphas. The most likely advantage you’ll see when using the 32 export format is that, once a satisfactory alpha depth factor has been determined for your export needs (set by the Alpha Depth Factor slider in the Alpha palette), you will not need to change it when subsequently exporting new versions of the same displacement map. You may also find that you do not need to adjust the alpha depth factor even when exporting different displacement maps. We recommend exporting in a 32 bit format, if your target program can read this format.

4.3. Distributing Information Across Channels A standard TIFF file can contains anywhere from 1 to 5 channels, with 1 (for grayscale images) or 3 (for color images) probably the most common. ADE exports TIFF files with either 1 or 3 channels. In addition, each channel in a TIFF file may be 8 bits, 16 bits, or 32 bits. A 16 bit alpha displacement (as exported by ZBrush) requires 16 bits of data per point. The most straightforward way of achieving this would be to use a TIFF file containing a single channel, with that channel having 16 bits of resolution. There are other ways of achieving the same effect. All that is necessary is that the TIFF file be able to store 16 bits of information for each point in the image. For example, a TIFF color image file usually has three channels of information, with each channel storing 8 bits of color data. This means that each point in the image has a total of 24 bits of data associated with it. We only need 16 bits of information per point to store a ZBrush displacement map, so we can still use this image file format; for example, 8 bits of information could be stored in the red channel, 8 bits stored in the green channel (for a 6


total of 16 bits), and the blue channel could be ignored completely. Attempting to view such a file using a color viewer would result in an onscreen image the would probably look like an insane artist had painted a picture using just Day-Glo colors, but that’s just because the viewing program would be trying to interpret the data at each point as a color, when it is in fact meant to be interpreted as a grayscale intensity stored in an odd manner. Doing something like this means that, in effect, one “conceptual” channel of information is spread across more than one actual channels in the file. This is important because programs importing displacement maps in TIFF file format may expect that data to be arranged in different formats within the file. The reasons for this are usually historical. In the past, not all variants of TIFF file formats may have been readable by all programs3, so improvisations like encoding a 16 bit grayscale image into a 24 bit color image were used to move data around. Over time, some programs came to expect such workarounds as normal, and since these workarounds became accepted practice, that’s still the way it is today.

5. ADE Interface This section describes the various controls and settings available in the ADE interface. In conjunction with the conceptual information provided earlier, this will allow you to define an ADE configuration to meet your needs.

5.1. Starting the ADE You access the ADE via the DE Options button in the Alpha palette: press this button to bring up the ADE interface, described below.

. Simply

Once you have configured the ADE to your satisfaction you can use the Alpha:DExporter button to export your alpha data without bringing up the ADE interface. See section 7 for details.

5.2. ADE Interface Layout The ADE interface can be divided into various control groups and individual controls as shown below:

3

This is probably still true.

7


is a set of twenty buttons allowing you define up to twenty different alpha export configurations. Each configuration remembers its own values for the different options available to control file export. For example, you could have configuration buttons labeled Maya®, Softimage®, and Lightwave®. Each of these buttons would define a set of option values appropriate for creating and exporting alpha displacement map files for use in the given external 3D package. Configurations

The predefined configurations that come with the ADE are suitable for use in exporting to many other 3D applications. See section 6. The active configuration is the one whose button’s background is drawn in yellow. In the above image, the active configuration is the one called Float32. You can change the active configuration simply by pressing on a different configuration button. The Options sections shows, for each option controlling some aspect of the exported file format, the value of that option as it is defined in the active configuration. If you click on a different configuration button to make it the active configuration, the values of the options in the Options section will change to show the option values stored in the newly selected active configuration. If you can use a predefined configuration, or find a quick code to meet your needs, you’ll never need to worry about this section. The Status toggle button plays a special role. Its most obvious effect is to enable or disable the Options section; you will only be able to set options when the Status button is On. However, this button also comes into play when exporting files, and we’ll discuss that a bit later on. The Quick Code is an easy way for you to enter options defining a new configuration. Think of it as the number appearing alongside many TV listings, that you can enter into your VCR; by entering that number, you automatically program the VCR with channel, start time, end time, and how many days of the week a show should be recorded. The quick code is the same thing for the ADE.

8


The most convenient way to enter quick codes is using the Paste button described below, but it can also be entered manually. Click the quick code field and type the quick code in the resultant entry field. If you have developed a custom configuration and want to name it, click the quick code field, press the right arrow button to move the cursor to the right of the resultant text field, and then replace the characters after the last hyphen with the desired name. The Copy and Paste buttons copy the Quick Code from, or paste the Quick Code to, the system clipboard. If someone else has developed a configuration perfect for use with your favorite external program, they can post the Quick Code to ZBrush Central or some other forum. You can then copy that Quick Code from their message onto the system clipboard using whatever method is standard for your operating system, and then use the Paste button to paste the Quick Code from the system clipboard into the Displacement Exporter. This recreates their configuration inside your copy of ZBrush, without the need to set any options manually. And of course, you can do the same thing in reverse to share configurations you’ve found particularly useful. The Export and Cancel buttons at the bottom of the interface allow exporting files, or exiting the plugin. The Preview shows a small thumbnail giving an idea of what your exported alpha map will look like. For reasons we’ll go into later, this icon can appear colored, even though alphas are always interpreted as grayscale images. The preview is useful for feedback as you set options, as often you will be able to get an idea of whether or not a particular setting is correct for your application simply by observing its effect on the preview. Finally, the Normal Map Intensity Adjustment slider under the preview allows adjustment of the apparent depth of the normal map. See section 8.2.

5.3.

Configuration Options

Below is a set ADE options for a single ADE configuration. The title (name) of each option is given in light lettering on a darker background, and the value of that option is the underlined text to the right. Each option has a certain number of values it can take (for example, the Smooth option can be Yes or No, while the Channel(s) option can be 1 or 3). Click on an option to cycle through its allowable values.

You will not be able to change a configuration’s options unless the configuration’s Status button is on.

9


The configuration shown above isn’t useful, i.e. there’s no external program you’d ever use it with. The settings were chosen simply to show as many of the allowable values as possible.

5.3.1. Configuration Options Layout It’s easier to understand the configuration options panel if it’s considered as an upper half and a lower half. The upper half consists of various options affecting the exported file as a whole, while the bottom half consists of three pairs of settings, one pair for each of (up to) three channels in the output file. Visually, the grouping is like this:

With the possible exception of Scale, the options in the top half are fairly simple, so we’ll start with brief descriptions of them.

5.3.2. File Options Channels: Determines the number of channels in the output TIFF file. Possible values are 1 and 3. If the value is 1, then the settings that for channel 2 and channel 3 do not apply

and will be disabled. Bits:

The resolution of each channel. If Bits is 16 while Channels is 3, then the output file will contain three channels, each with sixteen bits. Allowable values are 8, 16, and 32 Float Vertical Flip: Yes

or No. If it is Yes, then the output image will be flipped vertically, which is necessary when importing into some other programs. Smooth:

Applies a slight smoothing algorithm to the alpha before exporting it. This may be useful depending on how the alpha was created. Seamless:

Set this to Yes if Smooth is Yes and the alpha is intended for use in a seamless tiling. It ensures that when smoothing done at an edge is done with consideration of the same point on the opposite edge, so that edge artifacts are not generated by the smoothing process. Scale: Scales the intensity range A.D. Factor, Auto+A.D.F., and Off.

of the alpha in various ways. Allowable values are Auto,

Auto:

Adjusts the contrast of the alpha to maximize the intensity difference between light and dark values. Many of the alphas you will work with or generate in ZBrush are automatically contrast-maximized, and in such cases

10


you will not see a difference. The two images below show the effect of setting this value off and then on:

The effect of the Auto setting also takes into account the range of values in the AlphaAdjust curve (found in the Alpha palette) and of the baseline intensity of the alpha. These settings will affect the range of values over which the alpha is scaled. •

A.D. Factor: Adjusts the alpha contrast taking into account value in the Alpha Depth Factor slider, which is found at the bottom of the Alpha palette in the

main ZBrush interface. Depending on the circumstances, the alpha depth factor many not have an effect on the alpha, even if this setting is on. •

Auto+A.D.F.

: Adjusts the alpha using both Auto scaling and the alpha depth

factor. •

Off:

No adjustment is made to the alpha.

5.3.3. Per Channel Options Each channel has two settings, identical across the channels; Range and Res.

5.3.3.1. Channel Range The allowable values for Range are Full Range, Positive, Negative, Baseline, and Zero. •

is used when creating a displacement map for a program that calculates displacements from a single grayscale map. Such programs typically use a 50% gray to indicate no displacement, and lighter or darker shades to indicate displacements in to or out from the original surface. Positive or Negative. Other programs might use two grayscale images and combine them to produce a full displacement map. One image indicates positive displacements, i.e. displacements coming out from the object’s surface, while the other image gives the negative displacements, going into the surface. When Range is Positive, the channel will be adjusted so that it includes only positive displacements from the original alpha, and similarly, Negative causes the channel to include only negative displacements. Baseline causes the channel to have a single intensity throughout, which is the baseline (no displacement) intensity. In ZBrush, this will normally be a 50% gray. This can be used to pass the baseline value to an external program Full Range

causes the alpha to be black (all pixels 0). This can be useful when there is a need to visually check the generated image file or to edit by hand, as Zero

11


unused channels can be set to black so they do not affect the viewed data in unpredictable ways.

5.3.3.2. Channel Resolution The Res setting is normally set to Full. Its other two possible values, Major and Minor, are used only when you want to achieve the quality of 16 bit displacement maps while working with a program that uses only 8 bit displacement maps. If you do not work with such a program, you do not need to read the next section.

Major and Minor Channel Resolutions ADE allows easy application of 16 bit displacements to external applications supporting only 8-bit displacements, by generating two files, a “major” file and a “minor” file. The major file contains 8 bits of data that represent the large displacements, and is applied to your external program first, with an appropriate scaling factor. If you were using displacement maps to generate a mountain range, this would cause all of the mountains and valleys to appear, but there wouldn’t be much in the way of detail, and the slopes might have a bit of a “stairstep” appearance, due to the low bit depth of the displacement map. The minor file is then applied in a second displacement pass, using a much smaller scaling factor; it fills in the details by making smaller adjustments to each previously displaced area.

6. Predefined Configurations The ADE ships with a number of predefined configurations. It is likely that one of these will be suitable for your needs. The name of each configuration is effectively an abbreviation for its use. The examples below illustrate this: •

D16:

PN8:

• •

Exports a file containing a single 16-bit channel with the displacement information from the alpha. This and D32 and D8 are the configurations you will likely use most often–they are the “simple” ways of exporting alphas. Exports a file containing two channels (actually three, with one unused) with a resolution of 8 bits each. Positive displacements are in one channel, and negative displacements in the other. R32: Similar to D32, except the file contains three channels with two unused; the displacement information is exported in the red channel. or Major8/Minor8 : Exports major/minor displacements in either a single file, or two separate files. D88

• N8: Exports a normal map as three channels of 8-bit data. Of course, you can tweak these configurations or define new configurations as needed. For explanations of the terminology used above, see section 5.

12


7. Exporting Alphas You can export your alphas using either the Export Current or Export Active Set buttons in the ADE, or the DExporter button in the Alpha palette. •

Export Current

exports a single file using the settings in the active (visible)

configuration. •

and DExporter both do the same thing. They export files for all of the configurations currently set to On. If you in the ADE, the configurations set to On will be displayed with their name in yellow text (except for the active configuration, for which you can simply look at the Status button.) Export Active Set

Multiple files are exported using a simple naming convention. For example, if you set the Major8 and Minor8 configurations to on, then pressing DExporter will bring up a save dialog with a file name something like AlphaName~Major8.tif. If you change this name to, say, Mountain~Major8.tif and complete the save, then two files called Mountain~Major8.tif and Mountain~Major8.tif will be automatically saved.

8. Normal Maps The ADE can also calculate and export normal maps based on the initial alpha displacement map. This makes use of the special values that can be assigned to the Range setting in each channel, and is briefly described below. If you are familiar with the concept of normal maps, these settings will be fairly obvious. If you are not familiar with normal maps, you’ll want to consult a reference on the subject before using this capability of the ADE. ZBrush already has features for creating normal maps, and the ADE options described here are not intended to replace those features. Instead, use the ADE normal map options if you need to export normal data in formats other than that provided by the standard normal map tools.

8.1. Normal Map Configuration Options A normal map requires three channels, one for each of the x, y, and z components of the normal at each point of the map. You can use the ADE to export this data as one file containing three channels of data, or three files containing one channel. Setting up a normal map export configuration involves assigning normal map components to channels; in addition, each normal map component may be negated or not4. These possibilities correspond to the values Normal X, Normal Y, etc. available in the channel Range controls of the ADE.

4

Whether or not a normal map channel needs to be negated depends on the normal map conventions of the program the map will be used in.

13


8.2. Normal Map Intensity Adjustment Slider The slider immediately under the alpha preview within the ADE interface is primarily intended to adjust the intensity (apparent height) of exported normal maps. The effect of this adjustment can be seen in the alpha preview. This slider can also be used to adjust standard displacement map alphas, but the results are sometimes unpredictable, and we do not recommend it for that purpose. This slider is not actually adjusted by clicking and dragging it. Instead, simply move the mouse cursor along the slider bar, and click where you want to set the new slider value. For example, here is a single alpha, viewed as a normal map, at two different slider intensities:

The colors are typical of normal maps when viewed as an image with three color channels, while the shading is added by the ADE to indicate the apparent depth that will be seen when the normal map is rendered. Use the normal map intensity slider to make last-minute aesthetic adjustments to your normal map, if you decide the map generated using ZBrush’s standard normal map features does not quite have the intensity you want.

14


Zbrush