Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: DHTML
Expertise: Beginner
Jul 25, 1997

How to create texture maps that won't be distorted by geometry

How can I create texture maps (for 3D objects) that don't get distorted by the geometry?

Use 3D Paint tools.

When I want to paint something in the real world, I pick up a brush, dip it in paint and apply it to the object. If I want to add surface textures, I may press rough shapes onto the surface, score it with a knife, stick decals onto it or copy patterns from other objects. But to give an object created on a computer the same colors and textures it has been necessary to wrap a texture or bump map around the geometry. Artists have created 2D map files in paint or image manipulation programs then applied them to the 3D surface. Matching up surface features of a plane and rounded surface can mean moving texture files to and fro many times.

Until 1995 there were no tools that enabled painting in 3D, especially for PC and Mac. Existing 3D paint programs are found almost exclusively on the SGI platform. Now, however, there are two desktop tools available (for around $500) that give much of the same functionality as the SGI programs but, of course, not the workstation level of performance. MeshPaint 3D is a 3DStudio Max plug-in that can be used independently, while Detailer from Fractal Design is a stand-alone product.

Texture mapping is a useful technique for adding detail to an object without creating a mega-polygon model. Putting a texture onto a simple shape such as a sphere or cube primitive means simply applying a flat, spherical or cubic map to the shape. But the more irregular the shape being mapped, the harder it is to deform and match up the pattern on a flat surface to the result seen after mapping to a solid geometry. After all, unless you're constructing a demonstration of scarring after plastic surgery, you really don't want joins on the face where the edges of texture maps meet. The technique thus far has been to use a 2D paint program to create a flat 'skin' to be stretched over the face's geometry. The skin has the eyes, nose, mouth and ears painted onto it, then the artist hopes it's going to look right when stretched over the shape of the head. The result is often eyes where the ears should be and weirder-looking aliens than on Deep Space Nine. So if you want to get those Bajoran nose wrinkles on the nose you should try one of the following products and paint directly onto the model's surface.

MeshPaint 3D v1.6 from Positron Publishing
Price: $500
MeshPaint 3D is available for Windows 95/NT (Intel), Windows NT (Alpha), and PowerMac. I tried it out on a 200MHz Pentium Pro machine with 32 MB of RAM, so my comments relate to that platform. When using MeshPaint as a stand-alone product, it can open a range of high-end modeling and animation tool formats: 3DStudio (.3DS, .ASC), LightWave (.LWO), trueSpace2 (.COB), Electric Image (.FAC) and QuickDraw 3D (.3DMF). The only textures it deals with are Targa, bitmap and .PIC files. This is rather limited for bitmap formats, and also with respect to the Internet geometry standard VRML. I had hoped it would have accepted VRML's .WRL format by now, but it's only at the export VRML stage, and version 1.0 export at that.

Still, there are VRML 1.0 to 2.0 converters out there for free so its not such a big deal. And MeshPaint does give you a choice of storing texture information inside or separate from the geometry file. It just uses confusing names for the files: 'inline' is the internally stored type while 'filename' lists the path to the texture image. When you use MeshPaint as a plug-in for Studio MAX or SoftImage, it supports their file formats. The documentation for this product leaves a lot to be desired and is certainly not targeted at beginners. It assumes you know a lot about setting up a 3D model and its texture-mapping parameters before you start working with MeshPaint. The Positron people tell me there's a better version of the manual on the way; I'm glad to hear it. Far too many parameters need setting on a trial and error basis. More detailed advice than the terse rules of thumb supplied in the manual would have helped with topics like setting texture map resolution and the type of mapping to use. In fact, they've clearly been inspired by Painter's range of natural brush types, so it's too bad Positron has not been inspired to produce as good a manual as Fractal did for Painter 4.0.

Before bringing your model into MeshPaint, you need to have labeled all of your surfaces. Up to 512 surfaces per object are supported. It then lets you select named surfaces and set a texture type for them. Whatever you finally draw in 3D will then be mapped, in the way you chose, onto the specific areas of the model surface. The texture map types MeshPaint supports are: Planar, Cylindrical, Spherical, Implicit (as in the modeling package where the model was created), and None. This last choice is useful for protecting areas upon which you do not want to paint. Objects first appear in wireframe view, so you need to set up rendering choices for texture maps before you can see the object as a solid. Each surface can have a texture map assigned to it, and all must be preloaded. Just use the Open Texture Map window and select the 2D image files you need. The comprehensive assortment of paint tools within MeshPaint can be used to change and adjust any texture map before applying it to an object. When you render an object, the title bars for the 2D maps appear at the bottom of the main screen. But bear in mind that all of these open images are occupying memory and potentially slowing down rendering performance. This also applies to the ability to open multiple objects at once — it's going to be a memory hog. Helpfully you can set up your Preferences to let you rotate objects as vertices or as a bounding box to improve performance.

To apply a texture, open the Assign Texture Map window, select a surface name and assign a map to it. For the first rendering of an object, the New Map window will ask you to set the map size and background color. The defaults are the size you set under Performance, and the color is white. The texture stays where it is first placed so you can adjust its appearance either by painting on the 3D solid or in the 2D window. Undo is available in case you make a mistake but the default setting is Off. This is a memory saving concept to prevent multiple undo buffers that exist for each surface of an object and soak up too much memory. You must set the Preferences feature for each map to which you want Undo to apply. If you don't have Undo enabled when you make a map, it won't work if you turn it on later. Depending on how powerful your machine, this feature is either a blessing or a curse.

If you need to change the texture map you've assigned to an object or surface, the Operations menu gives access to the Apply Texture Map window. If you want to start as simply as possible, just render your object using the New Texture Map option and click Assign to All. All object surfaces are then automatically selected. You then only have to set map resolution and color, which without much help from the manual is a matter of experiment and experience. Next, choose your brush and color. This is another of those time-consuming features, spoiling you with choices. It's impossible to produce a professional-quality tool without providing this sort of customizing facility. To be concise: You choose a brush or painting tool from the floating tools menu, a brush tip from the brush set and a color from the color set, and it's time to paint on the object.

I hope no one is going to try painting with a mouse, even though MeshPaint accepts one. You must have a graphics tablet; in fact, I upgraded mine in preparation for this write-up and am using Wacom's ArtZ II, with a pressure-sensitive UltraPen that flips over to erase strokes. It also has programmable buttons on the tablet to speed up frequently used actions. The tablets are indispensable for the computer artist.

Now back to MeshPaint: Once you start painting in one of the windows, the other window will automatically update, so you can paint in 2D or 3D. But remember to open the 2D window to see what is happening in it, because it doesn't open by itself. How good the real-time feedback is depends on the power of your computer and the number of windows that are simultaneously open.

A range of painting tricks is available in MeshPaint. Clone painting does the 3D texture replication from one part of the object's texture to another as you paint. BrushHose is similar to Painter's ImageHose and lets you shuffle through selected brushtips in real-time as you paint. Each sequence of brushtips must be set up before starting the hose. The ability to paint across multiple texture maps interactively is a nice new feature. The brushes are infinitely adjustable, so you can achieve any effect with enough experimentation, then add new brushtips to the library. In case that isn't enough, there is a range of color effects that can modify the brush stroke. I like the Chroma Stripper, which can reduce a figure to greyscale while surrounded by a colored background scene. Any image up to 64x64 pixels can be made into an image brush by cutting out the image, converting it to a stamper, and selecting Create Brush from Stamper on the Operations menu.

In addition to all the brush controls, MeshPain also contains more conventional drawing tools for producing straight lines, ellipses and rectangles. When selecting line colors, you can choose to work with the Windows color wheel or MeshPaint's own slider-controlled mixer. A useful feature is the ability to create and save custom palette sets of up to 300 colors, and to resize the ColorSet window to include as many of these colors as you need to see.

The feature that alone might convince you to buy MeshPaint is PolyMap. It enables you to outline and unwrap the polygons in a 3D object into a 2D pattern — a very useful feature if you need to paint polygon-by- polygon. The PolyMap can be saved as a 2D file and used to guide accurate painting. The higher the map resolution, the more usefully detailed the PolyMap will be. But remember to set the brush size to one pixel and the color to something that will stand out against the object's background. With no undo set, it's very annoying to have to scrap the file and start again because the brush was too big or the resolution too low.

MeshPaint's most important feature for 3D graphics professionals is its ability to work as a plug-in with 3Dstudio MAX or SoftImage. Adding it as an extension to your most commonly used tool makes a lot of sense. The one feature MeshPaint has lacked so far is layers, so that it can be more used more effectively with Adobe Photoshop. This is to be remedied in the next release. Version 2.0, due at Siggraph, will feature a new rendering engine that supports Direct 3D and will enable display of bump, specularity and transparency maps. A bitmap mover will enable adjustment of a texture map's position on the object. This product is getting better and better.

Detailer from Fractal Design
Price: $449
Detailer comes complete with a 3D modeler: version 4.1.2 of RayDream Designer (current offer lasts until the end of March '97, but may be extended). This is a spin-off bonus from the fusion of Fractal and RayDream. Designer is available for both PowerMac and PC, but the PC version runs only on 32-bit versions of Windows that support Direct3D: NT (v4.0) and Win 95.

The native format for Detailer is RDD and is included in the extensions to RayDream Studio or Designer that come with the program. Detailer can import 3DStudio DXF and 3DS files as well as Apple's 3DMF format, and supports the QuickDraw 3D display and rendering features as well as Microsoft's Direct3D. This means hardware acceleration is available on whichever platform you're using. Detailer supports a variety of 2D formats including RIFF, PICT, TIFF, JPEG, Photoshop 2 and 3, complete with layers. The support for layers may be one of the reasons you might prefer Detailer over MeshPaint. Fractal intends to provide more file formats as plug-in modules for Detailer, but also hopes to convince developers of 3D packages to include the Detailer native format as one of their file choices. At the time of this writing (June '97) no support for VRML had been planned.

If you're used to the Fractal Painter v4.0 interface, Detailer will feel comfortingly familiar. Using this interface has some pluses for familiarity but some minuses for those who feel initially overwhelmed by the intricate controls. Detailer has even more windows and palettes than Painter, so it will take a while for a new user to come to terms with them. However, it comes with wonderfully helpful documentation. Another bonus is its materials libraries: Detailer ships with more than 100 textures and patterns, plus images for creating texture maps, and 3D models from Viewpoint DataLabs.

I started out with Detailer's sample project. Setting up a basic 3D model just involves opening a model, in this case a sphere, clicking on the brush icon and on the sphere to bring up the Load Texture Map window. To use a prepared 2D image, choose Open Image, and from the next window, select the file to load. The final decision is which type of mapping to use. The choices offered are: cylindrical, spherical, pass-through, cubical, or implicit (also known as UV mapping). This map was to go on a sphere, so I chose spherical. (If you're using Ray Dream Designer it can provide UV coordinates, as do all advanced modelers.) To improve the lighting of the rendered sphere, click the light bulb icon in the Materials palette. Sliders control ambient lighting as well as a range of parameters such as brightness and exposure. There are lots of controls over the lights' position, color, etc., all simple to use. I felt at home with this interface right away. To start painting on the model, I chose the brush tool and a brush type from the brush palette. The Natural Media brushes are transferred exactly as found in the Painter interface. I picked a color from the palette and started painting. It's that easy.

When you're painting, the 2D map updates at the same time as the 3D model, but to optimize performance you can just paint in 2D and turn off the 3D display. Click the Object icon in the Materials palette. Click on the eye next to the texture map entry — when the eye is closed you can only paint in 2D. To see the mesh while you're working, turn on the Display Mesh choice. If you make a mistake there are 32 levels of Undo available, but you must set the level of Undo you want — the default is five levels and applies just to the map images. Also, at each level of Undo you must save all the document data at that level, so be careful how many levels you permit. When possible, Detailer saves the data in memory but may have to write it to the hard disk, and calling Undo may then slow you down somewhat. The user guide gives a useful run-through of the program's areas that have high RAM requirements. I found the list of memory needs for various display sizes of the 3D model worth bearing in mind: A 640x480 display will take up 15 MB of RAM. One memory problem when working with large and complex models is the need to keep all the map windows related to a model open until you are completely finished, or the links between model and map are lost. This leads to a cluttered screen with window upon window, although a particular map can be found and activated from either the Map menu or the Object palette.

Detailer makes it very easy to create not just texture maps but also bump, specularity, transparency and environment maps. This is a feature I didn't find in MeshPaint and is very useful when trying to achieve a realistic look while using the minimum geometry modeling. Finally, render or export your model and maps. Detailer can render an anti-aliased image at any resolution but is slow, so you'd probably do better to finish the job in your modeling program.

Conclusion: Both of these products are useful components of the 3D digital artist's toolbox. Which one to go with depends on the other tools you use. It's undeniable that Positron's MeshPaint fits well with 3Dstudio MAX and SoftImage 3D because it functions as a plug-in with either program. So if you're already using one of these products I'd go with MeshPaint. If you're using less expensive modelers, Detailer makes good sense. Each program has specialities: Detailer with floaters and Natural Media brushes, MeshPaint with PolyMap and individual surface texture selection. I would choose Detailer for compositing models into scenes but prefer MeshPaint for control over detail with 3D models. My wish list for each product would be for each to add the features of the other into itself and improve memory management.


Fractal Design's Detailer: www.fractal.com/products/detailer/
Positron Publishing's MeshPaint3D: www.3dgraphics.com/meshpaint.html

Higher-end 3D Paint programs: 4Dvision's 4Dpaint for Win 95 and NT: www.4dvision.com/4Dpaint.html
Price $950
Digits 'n Art's Flesh for SGI IRIX: www.dnasoft.com/flesh.html
Price $9,995
Interactive Effects' Amazon 3D Paint for SGI IRIX (with Amazon Paint): www.ifx.com/spec_3Dpaint.html
Price $5,000

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date