HowTo:FullUnwrapStarkOp

From VsWiki
Jump to: navigation, search

A Stark Choice

First, you have a delicate decision to make: To mirror, or NOT to mirror.

Assuming your mesh is mirrored in X (i.e.: your mesh object has the Mirror attribute turned on), to unwrap it as-is makes the unwrap itself "mirrored"; and to unwrap it un-mirrored you have to first Apply the Mirror attribute.

If your ship is NOT mirrored, --presumably because it's not supposed to be symmetric--, then you don't have to deal with this question; you are forced to unwrap it un-mirrored.

What you cannot do as of this writing (with the Vegastrike engine and Blender as they are) is to mix mirrored and un-mirrored unwrapping, or to overlap some of the uv islands but not all. This is because Blender's ambient occlusion baking adds light from different mesh areas using the same area of the texture; which is fine if ALL areas are used twice (just a matter of defining the ambient light as 50% grey), but otherwise making much brighter overlapped than non-overlapped UV islands.

So, basically, we have two choices: Mirror the whole ship's UV mapping, using every UV island exactly twice; or not mirror at all: make each UV island represent a unique area on the mesh.

But as for the not too distant future, the VS engine may start using something smarter than ambient illumination baked into the glow texture: Global Illumination, or "GI"; which would give us a more dynamic kind of ambient occlusion, with soft-edged shadows from self-shadowing, sensitive the dynamic, global light distribution. But GI uses two extra textures, called PRTN and PRTP, which require a special baking setup in Blender, and together encode light contributions from all 6 orthogonal directions, to each texel. But these PRT's cannot use a mirrored UV-mappings, or any kind of UV island overlap, at all. Note, however, that these PRT's won't need to be big textures. Typically they'd be one half or one quarter the resolution of the diffuse and specular textures.

But also, in the not too distant future, we'll have dual UV-mapping (two UV-coords per vertex in the mesh file) So, we could then have high rez textures using a highly mirrored and overlapped UV-mapping, and PRT's using a non-mirrored and non-overlapped UV mapping. Blender already supports multiple UV's per vertex, although, yes: I'm afraid this would place on us the extra burden of producing two UV-unwraps for each mesh; but the results should be spectacular.


To put the current situation in summary form:

If your ship is non-symmetric, and therefore you don't have a Mirror Attribute on your mesh, you're probably best off making a full ship UV mapping, without any UV island sharing. If your ship is symmetrical and you have the mesh itself mirrored, you have a difficult decision to make: Do you unwrap it as is --i.e.: unwrap half of the ship and then apply the mirroring, so that the other half has the same UV coords as the first, or to apply the mirroring first and do a full mesh unwrap. (And there's a third option I'll mention later.)

Here's the advantages for each:


Mirrored's Pro's:

  1. It is easier (half as much work), to unwrap.
  2. Packs twice as much detail in a given texture.

Mirrored's Con's:

  1. The two sides of the ship look exactly the same: Which means that near the middle line, a scratch on one side will be mirrored exactly on the other, so one has to avoid putting such circumstantial or accidental details where they can be seen on both sides of the ship. like, say, from above it; forcing you to have a central band of featurelessness or risk making the mirroring too obvious.
  2. The two sides are mirror images of each other: Readable text in one side of the ship will read backwards on the other side.
  3. You may face some trouble with tangent space normal mapping, which tends to produce inverted results when the clockwise order of the UV vertices is inverted, as it is in the mirrored side of the ship. xNormal, a free program to bake normal maps from supplied coarse and fine meshes, supposedly now handles mirroring; but I have not tried the feature yet, myself; and I'm not sure I imagine how it works when combined with a supplied bumpmap.
  4. Wasted work as far as future engine feature compatibility is concerned: A mirrored unwrap isn't only useless as a PRT UV-mapping; it is also not exactly optimal for the diffuse- and specular-only UV unwrap; because for that unwrap you'd probably want to mirror some items in X AND Y, or even in X, Y and Z; and you may have repeating greebles that could use the same UV-island a dozen times. Once we have dual UV coords and can depend on the non-overlapped mapping for things like PRT and normal mapping, we can essentially do anything we want with the other unwrap. So, in a nutshell, your mirrored UV unwrapping is destined for the recycle bin, eventually.

Un-mirrored's Pro's:

  1. It's un-mirrored :D, which means, you can have a scratch just to the left of the middle line of the ship that doesn't show on the right of it; and you can have text that reads properly anywhere around the ship.
  2. No trouble with tangent space normal mapping.
  3. No trouble with PRT's
  4. Forward compatible with dual UV-mappings: Your unwrap will simply become the "PRT unwrap", and you'll have just one more unwrapping to add; --namely, the mirrored and higly UV-island re-use mapping.

Un-mirrored's Con's:

  1. Less efficient, from the point of view that the left and right sides of a symmetrical ship are almost identically textured, so we're sort duplicating a lot of info. However, the accent is on "almost"...
  2. More work. However, there's tricks we can use to lighten our burden. See below.


The promised third option:

      • NOT recommended though.*** One can have a mirrored texturing, but leave some room in it; then un-mirror the ship, and then UV-unwrap a few items so that they aren't mirrored, such as special places to put writing on. The reason I don't recommend this is you will still have to deal with ambient occlusion baking snafus that are manageable but which I don't intend to write a tutorial for. And all the other con's of mirrored UV mappings are still applicable.


If it's not clear from all the above, I am biased towards non-mirrored UV-unwrapping :D; and therefore, for this tutorial, I will do a full, un-mirrored unwrap. However, I'm as lazy as the next guy, and I will use a trick to do half as much work as unwrapping the whole, un-mirrored mesh.


The Trick

The trick consists of the following steps:

  1. Unwrap half the ship (without Apply-ing the Mirror Attribute), but only onto half of the UV texture space.
  2. Apply the Mirror Attribute.
  3. Select the newly created half of the ship
  4. Move its UV layout islands as a block to the unused half of the UV texture space
  5. Mirror its UV layout as a block, so as to restore proper clockwise order of the vertices.


The general layout

This is what Blender's UV texture image editor looks like:


blender_shot90.png


Notice that, by default, its grid-lines divide the area by powers of two. It is very important to use these grid lines, because mipmapping scales down the texture by powers of two, and to the extent that our UV islands cross major lines, we get more boundaries between islands that are NOT aligned with power of two subdivisions, which causes earlier mipmap "leakage" between islands. As I mentioned before, this problem is much lesser if the inter-leaking islands are of similar colors; which is why we want to group our islands by similar materials... But I'm getting sidetracked.

So, as per step 1 of the trick above, we'll unwrap our ship onto the bottom half of the texture, more or less as follows:


blender_shot91.png


The plan may change, though, as we come to face the practical necessities, but just to have a plan. What's most important in this tentative layout is the Front and Back squares on the left: We want to keep front and back views REALLY separate from the other views. The reason is that, once we get to texturing, when we want to simulate dirt trails, "air marks", scratches, etceteras, we can easily do that by generating noise masks and motion blurring them or smearing them towards the right. But if those smears cross our front- or back-facing islands, they will ruin them. So, by keeping front and back face views together on the left side, we simply select that region on the noise mask and erase its clumps before we smear it. And it also makes it much easier to find things in the UV layout if you just know where all front-facing things are, where all back-facing things are, etceteras. For the same reason, all the top, side, bottom views on the right hand side must conform to a very important rule: Front of the ship is towards the left on the texture; back is towards the right. Otherwise, the smearing trails will sometimes seem to go backwards, or vertically, or whatever.

NOTE: If you think UV-unwrapping is a lot of work, you haven't done any texturing yet. Any extra work during the unwrap that will ease the texturing work is a very good idea.

So, then, as per step 2 of the trick, we apply the object's mirror attribute. At that point, the second side of the ship will "materialize", but all its vertices' UV coords will be the same, still using the bottom half of our texture. So, we'll switch from UV Face Select (potato) mode back to Edit mode, select the newly materialided half of the ship, switch back to potato mode, press A on the UV Texture Edit window to select all, and move it all up exactly half our texture's size number of pixels:


blender_shot92.png


But there's one more thing to do. The problem is that our new ship half's UV vertices have inverted ordering (which I'm representing by the blue color), which will cause normal mapped grooves on one side of the ship look like crests on the other side. To solve this problem, with the UV islands still selected, we do a vertical flip:


blender_shot93.png


BINGO! Then we'll be ready to texture.

Only problem is, we haven't actually done step one yet... :D