Showing posts with label UV. Show all posts
Showing posts with label UV. Show all posts

Friday, 9 May 2014

Head Texture UV Unwrap

I've been working on the controller and animations and this has led me back to character creation.

I have tried creating my own animations and although acceptable they are not as good as those I can purchase for a modest fee for use with the Unity3D Mecanim system.

In the process of trying out the purchased and a few free bundled animations with my own models I have found some shortcomings with my skinning.  To fix that I have tried Mixamo.  It did a fantastic job of adding a rig and skinning my character.

The test animations also showed where my mesh needed improvement.  Before I create a final skinned mesh using Mixamo I decided I should fix the mesh and that led me eventually to recreating the UV map for the characters head.

Texturing a Head

I have never textured a human head before so to remind me of the technique I used I decided to put it down in this blog.

There are loads of tutorials out there for UV mapping and texturing but the two I found most useful are:
For UV unwrapping: http://bgdm.katorlegaz.com/lscm_tute/lscm_tute.htm
For creating the texture for the head: http://www.3dm3.com/tutorials/maya/texturing/
This one also has a fully body tutorial but was also helpful: http://cgi.tutsplus.com/articles/game-character-creation-series-kila-chapter-3-uv-mapping--cg-26754

I am not going to go in to detail because those tutorials do that.  I am just going to mention the bits I wanted answers to.  The only thing to mention about the tutorials above is that the version of Blender mentioned is an older version. For me the standard Unwrap method created the head UV in one go without any adjustment needed.




Where to create seams?
I decided:
- From just above the hairline back over the head to the back of the neck.
- From under the chin down the centre of the neck at the front
- Across the mouth
- The eyes should be separate and therefore already a hollow cutout

I tried a horizontal cut on the forehead but I found this made it difficult to add hair without a visible line.




Do I separate the ears?
I had seen some examples with the ears being removed and dealt with separately.  I tried that and found the joint was visible.  For me it works best if I keep the ears attached.

Can I use a downloaded head texture created for another model?
No.  I tried adjusting the UV to fit a texture and it did not work.  It was stretched and all wrong in places.  What worked for me was to create the texture to fit the UV map as generated by Blender.  The generated UV has done the maths to minimise stretching.

Basic Technique

Start by exporting the UV map from Blender.  You won't get very far unless you know what you are trying to line the texture up with.  The exported UV image gives you a semi-transparent texture with lines on to use as a layer in your photo editor.



Creating the finished texture is also all about layers.

I started with a background of skin colour.  This was created using photo of a face.  Using the clone tool in Gimp I extended the flesh in all directions until I had a rectangle of flesh.  The important bit is that it retained tonal variation, so it still looked like skin.

The result was still very rough with duplicated wrinkles and blemishes.  I used various blurs and finished with a giant size smudge brush with an opacity of about 60% to end up with an even result.


That skin is the base layer over which everything else is added.

The next layer I created was for the eyes and nose taken from a different photo of a face.  I feathered the edge by using a large erase tool with a faded edge.  It was deliberately a freehand rough cutout so the blend was more natural.  I kept the eye brows as well.

I repeatedly scaled the layer until the eyes lined up with the UV map.  I then scaled vertically to get the nose the right length.

I used small clone and smudge brushes with blurred edges to make the area round the eyes redder and remove any overlap of the eye in the photo with the UV map.  I then filled in the eyes with the same colour and smoothed the result using the smudge brush.

I smudged out the nostrils from the texture because my model has geometry to form those and it looks odd if the texture does not align with the geometry of the nostrils.

I added a layer for the mouth and adjusted the scale to fit the UV map.

The same with the layer for the ears.



For all the added layers above the skin I set the opacity to 50% so they all blended nicely.



At this point I decided to try it on the model and I am pleased with the results.



I added blemishes and the hair the same way using additional layers.



In my opinion hair looks best as a separate mesh made of strips so the hair in this texture is just a placeholder.

Now that is done I can add the rig and skinning information using Mixamo.


Saturday, 10 March 2012

3D Modelling Reminders - UV Unwrap

I spend most of my time writing XNA code so when I return to modelling I have to remember the best techniques from the last time I created a 3D model.

I am sure I have put a few other reminders on this blog but while I'm creating what I hope will become the rocket launcher for Diabolical: The Shooter I am going to write down a list of key points as reminders for next time.

This is not a tutorial it is a list mainly for my own benefit that may point others in a useful direction

I tend to use a trackball for modelling rather than a mouse.  I find it more precise.  I use a cordless Logitech one and reassign the middle mouse button to both of the extra keys on the mouse.  This makes moving about in Blender much more reliable as my thumb is used to push on the buttons.  Works for both mice and trackballs.

There are some design choices that I make that may not be applicable to everyone.  These models are used in game so draw performance is important.  To maximise that I am trying to produce the models with the minimum number of draw calls which means using the minimum number of separate texture files.  For nearly all models I want to only use one texture no larger than 1024x1024.  For some I might use 2048x2048 and for small objects I go as small as possible without spoiling the result.  512x512 or 256x256.

The basic list of things to do:

1.  Create each part of the model as a separate object in Blender.
This is helpful when UV Unwrapping the model to be able to do it in small chunks.

2.  Just before UV Unwrapping create a vertex group for each object which contains all the vertices for that object.
This is useful because at some point it is easier if all the objects are merged in to one mesh.  Having a vertex group for the previous separate parts makes minor adjustments easier.


3.  Carefully mark the seam for UV Unwrapping.
Think about how the 3D shape can unwrap to be flat with the minimum of stretches.  Remember how you want the material to flow and try to put the joins out of sight.


4.  Select the same uv texture as the other objects.
Typically each object reverts to new.  Just change the drop down in the UV Image Editor window.

5.  I tend to find I am working in edge select mode for uv unwrapping.


6. Use the basic UV Unwrap option from the Mesh menu.


7. I am rarely happy with the immediate result so change the options from the context menu.
This is where Blender's interface becomes a little confusing.  The required menu only appears AFTER the Unwrap function has been completed and it tends to appear hidden at the bottom of one of the side menu bars.
The first time I use it I have to open the properties window and scroll down until I find it.  From then on it is where I want it.


The default settings are likely to have produced a twisted result which may be better in some ways but which I find difficult to texture.


8.  Before doing anything else change the Unwrap Method to Conformal and see if the result is going to be easier to texture.
Sometimes it is and sometimes it isn't pick whichever looks best.


I've already written a separate post just on that bit:
http://blog.diabolicalgame.co.uk/2011/10/uv-unwrap-in-blender.html


9.  Resize the UV so that everything will fit on the texture without overlapping.
Difficult to do at this stage because you can only see the individual object.  Make a guess and later on merge all the objects in to one object so the UV map can be arranged properly.

I find swapping between keeping the UV map and edit mode in sync or not in sync is useful for manipulating the UV.


In UV Sync mode use 'L' in a 3D view window to selected linked sections of the model.  They will highlight in the UV edit window making them easy to find, scale and move about.



You can temporarily move stuff off the texture to keep it out of the way while you manually reposition maps to get the best fit.



Including typing this blog it has taken me nearly 6 hours to UV unwrap the model and manually lay that out on the texture.  That's it for now.  I need to get on with creating the texture image.

Wednesday, 5 October 2011

UV Unwrap In Blender

I have just worked out a way to unwrap models in Blender that produces a result that makes it much easier when creating and working with textures outside of Blender.  I thought I'd better write it down before I forget.

The default options on my setup produce some strangely stretched and distorted results and it is difficult to fit them on the rectangular shaped textures.  I have tried all the clever methods on the drop down list of unwrap choices and always end up using the standard unwrap even though I had not been entirely happy with the result.




Now, using the same menu selection, I have at last noticed the tools options panel appear at the bottom of the tool window, usually on the right hand side of a 3D window.  If you have expanded the little plus and if your screen and Blender window are big enough to see the bottom of the main tool list!

"I think this is why Blender has a reputation for having a difficult UI."

The Unwrap window ONLY appears AFTER you have pressed the Unwrap button and goes away again as soon as you move on to another task!

Look out for this small set of options:




The bit that now makes the Unwrap do exactly as I would like, is the method, 'Conformal'

Don't ask me what that means I have no idea.  What it does is to make all the shapes stay as close as possible in proportion to each other and not distorted.  So a square remains a square and not a squashed rhomboid shape that I used to get.  You have to change the default, 'Angle' option to 'Conformal', every time.  I don't know how to default to 'Conformal' yet.




I find this arrangement much easier to work on in GIMP to align the textures to look correct.  I use the Export UV menu item and use the result as a layer in GIMP and just hide it before saving the final texture.

Back to Blender...

As mentioned above, the odd thing about some Blender options is that they don't become visible until after you have performed the action. When you change the option, in the temporarily visible tool window, the result of the action is changed.   In this case you Unwrap the model to a mess and then change the option and it all neatly lines up for you as you watch.

It can only do as good a job as the seams you have marked, so I spend a lot of time in advance ensuring that all sections of the model can be unwrapped to a flat shape without having to stretch too many of the edges..


It's a bit labourious but just select an edge or two or three and press the 'Mark Seam' button.  Change your mind, select the same edge and press, you guessed it, 'Clear Seam'.  You can Unwrap again and again, to try it out.

Anyway, as I started out by saying, I have found a UV Unwrap method I am happy with.