HowTo:Unwrap

From VsWiki
Jump to: navigation, search
arrow_left.png Creating Ships in Wings3D arrow_up.png HowTos Using Blender to unwrap models arrow_right.png

This article is intended to cover the topic of unwrapping meshes on both basic and advanced levels.

Cautionary note

Please do not use multiple textures, like one for each material... least of all tiling textures. If you're used to modelling but have never modelled for games, you might be in the habit of using multiple textures. That's a unacceptable for ships or stations--it slows the video card to a grinding halt. Please follow the guidelines below to make a UV map unwrapping to a single texture. And if your favorite tool doesn't do it, we recommend that you use Blender (or Wings3D for simple jobs.)


Unwrapping Basics:

FIXME - write tutorial!


What is a UV map?

An abstract representation of a texture (or texture-to-be) for a 3D mesh. As if you peeled off the skin of your model and flattened it out. I say "abstract" representation because the UV-map doesn't specify, for instance, the actual dimensions of the texture in pixels --it's just a dimension-less square--; nor does it specify how many colors [bit depth] the image will have. UV-unwrapping your model is an interactive process in Blender. There are scripts that automate it, but don't work very well (too many islands, unintuitive placement, lack of mipmap optimizations. One of these days, maybe... But not yet as of this writing. Once you unwrap your model, you export the UV-map layout as an image, and you can start your texture set from copies of this image, for guidance. All the images you generate in texturing a model (diffuse, specular, emissive, bump/normal-map) use the same UV-mapping. The Vegastrike engine is image-size agnostic, as long as you use powers of two. For example, your diffuse texture could be 1024x1024 and use 16-bit color, uncompressed; your emissive (glow) texture could be 512x512 and use 24-bit RGB compressed as a jpg, your specmap could be 2048x2048 monochrome, etc. The mapping scales to the image size.


How does a UV-map work?

When you UV-unwrap, each vertex in your model is given two new little numbers, called "U" and "V", that specify the x and y coordinates, on the texture, where it is represented (and painted ;-)). That's all the GPU (Graphics Processing Unit --the chip with the big heatsink on your video card) needs to know. For any given triangle, knowing where its three vertices map on the screen, and where those same 3 vertices map on the texture, the GPU can calculate how to hopscotch along the texture to make a linear traversal corresponding that triangle, in the current scanline. (May sound like a lot of computations to do so fast... but it's true; that's why the heatsink is there... :D)


How do I unwrap my mesh?

Each 3D modelling app has its own way. Google around for UV-unwrapping tutorials for the app you use. Here's some for Blender:


General Guidelines:

Mipmap-Friendly UV-mapping:

For a UV-layout to be mipmap-friendly, you need to subdivide the texture space into zones that are power-of-two fractions of the full texture in x and in y. Zones can be rectangular, of course, but they must meet the following simple rule, independently in both x and y: A zone's starting line must be a multiple of its size.

Example: Let's assume the texture is 1024 by 1024 --rather than speak in abstract terms of fractions of width--, and say you need a rectangular area for a long strip kind of shape, about 4:1 length-to-width ratio, and that you decide it could do with 256 x 64 pixels. With an x-size of 256, good placements are at x=0, x=256, x=512, and x=768. An example of a bad placement would be starting at x=128, not to speak of x=73 or somesuch. That's the reason the grid in the UV window goes by powers of 2 (at least in Blender it does ;-)).

Similarly, you can place that strip, vertically, starting at any multiple of its vertical size (64), such as y=0, y=64, y=128, y=192... but NOT y=32, or y=100.

The reason for all this is that, when the texture is sent to the videocard, mipmaps are generated on the fly, which are progressive downscalings by powers of 2, down to a single texel. At each scaling, each square set of 4 texels becomes 1 texel (average of the four), and the texture becomes more and more filtered. What you don't want is for that filtering to bleed color between islands. Subdividing the texture using the above rule minimizes such inter-island bleeding.

On the other hand, efficient use of the texture is as important as minimizing mipmap artifacts. And such mipmap bleeding is only noticeable if the colors of the inter-bleeding islands are different. Things on neighboring islands that will have similar texturing, therefore, can ignore the above rule, specially if they are continuous on the mesh itself --as in, the two islands being just the result of a seam separation.


Texturing-friendly UV-mapping:

Another guideline specific to WCU (but suggested as well to other mods) is we want to establish a "wind direction": We'd like to standardize the forward (nose of the ship) direction to the left, back (engines) to the right ("wind direction" left to right). Reason is, while working on the texture we can then use motion blurs globally to produce such effects as windmarks and scratches, which extend back from given points. If some of the front-to-back strips are horizontal, and some are vertical, and some go from right to left, wind-direction-wise, it becomes a tedious job to select and motion blur each section separately. Not to speak of other angles...


Neatness:

And since all longitudinal things would be oriented "left is front, back is right", then might as well also align them vertically, front to back (left to right) so that they make sense; and even order them vertically so that they make sense. So, let's say you could think of as grabbing your ship, nose to the left, engines to the right, sit it at the top of the texture, and unroll it down. So, front ailerons, if any, would be left from, and horizontally aligned with, the main wings on the right. It greatly helps with the texturing to have such orderings and alignments. Of course, often this isn't possible: --things like hardpoints and vertical rudders have to have their own islands outside of this unrolling continuum or else they might occupy too much space; but of course, small items can share space with other small items of similar size, rather than obey vertical alignment. But try, as much as possible, to keep some alignment rule, even for the smaller items, that makes it easy to figure out what's what, from where it is placed, rather than make the unwrapping a puzzle or IQ test.


Consistency:

Another general guideline, is keeping the scalings of the various parts on the same level. Exceptions to this could be things you want to look more detailed. Weapon hardpoints, for example, might conceivably use some nice texture greebling: round calibration screws and writings or warnings and locks and whatnot, and therefore could be enlarged, say about 2:1, relative to other parts of the mesh. Any part of the meshe where you plan to have some writing or pseudowriting, might be a good candidate for enlargement. Another exception would be things you want solid-colored... might as well scale them down to a single pixel. But other than such exceptions try to to keep all parts similarly scaled. In Blender you can load a test patter image, e.g.: checkers, that when applied to the UV-map should look even on the model, --rather than tiny squares in one place, big ones in another, stretched rectangles in a third...


To overlap or not to overlap:

Okay, those two engines on either side look exactly identical and would use identical texturing, so how about we just grab the island of one of them and place it on top of the island for the other, and only have to texture once? Almost a good idea, I'd say, BUT, if you intend to use Radiosity Baking (and you should), you should not; unless you're going to overlap EVERYTHING that is symmetrical, without exception. You can either go for FULL symmetry overlap, or NO overlap; --nothing inbetween. If you only overlap some parts and not others, it makes a mess with radiosity baking.

See also



arrow_left.png Creating Ships in Wings3D arrow_up.png HowTos Using Blender to unwrap models arrow_right.png