Blender 3D: Noob to Pro/Realistic Eyes In Blender
|Applicable Blender version: 2.49.|
[While pretty excellent up until that point -- especially as a hands-on example of real-world UV-unwrapping -- this tutorial cuts off midway, possibly merely a sixth of the way through the entire process.]
This tutorial will teach you how to effectively utilize textures and materials in Blender to create realistic eyes for characters. This tutorial was inspired by a great Maya tutorial in the Gnomon Workshop series by Alex Alvarez. My goal with this tutorial is to teach you how to get those same stunning results using Blender. Please check out Alex's tutorial as well, as it is very informative and covers more detail than I will be covering here. This tutorial assumes you know your way around the Blender interface and so I will not explain each key command as I go, but will instruct you in what steps to take and point out details such as key commands only when it seems relevant to do so. In addition, you will need some sort of image manipulation software, as this tutorial relies heavily on image-based textures, which we will be preparing outside of Blender. I will be using Photoshop, but feel free to use GIMP or whatever you're comfortable with.
Above is an example of what can be achieved using the techniques described in this tutorial.
OK, let's dig in...
Let's Take a moment to familiarize ourselves with the anatomy of the human eye. Do a Google image search and examine whichever diagram is to your liking. Now, you don't have to pay attention to every single feature, but do take note of the cornea, the iris, the pupil, and the sclera. These are the only parts that are visible to us when we look at a person's eyes, and therefore the only parts we will actually need to create. Many of the diagrams you find out there will be disproportionate, and so in order to know how large to make our features in relation to one another, it is best to view a large number of diagrams, a large number of eye photos, and also photos of plastic models of the eye, as plastic models tend to be truer to scale than 2D drawings. I also found a photo of a guy popping his eyes half-way out of his head. All of these together gave me a good feel for what the appropriate proportions are for a human eyeball. To some extent though, cornea size and sclera shape will vary on a person-to-person basis, so there is no precisely correct size, per se.
Building The Eye
Creating a UV sphere. 24 segments, 24 rings, and a radius of 1 is recommended. The top of the UV sphere will become the cornea of the eye. So now let's go into side view, in the orthographic view, and with the topmost vertex selected and proportional falloff enabled, grab and raise this vertex along the Z axis. Don't click to finalize the edit just yet - first we will use the mouse wheel to control how much falloff is going to be applied. This process can require some finess and multiple adjustments until the bump of the cornea is anatomically correct. You will want to set the falloff shape to "sphere".
Below is a render of the curve I ended up going with. You can use it as a guide when modeling if it helps you. This is with a SubSurf of 3 applied, so keep that in mind.
Now, some people may prefer to use a NURBS sphere for the geometry of their eyeball. If you are comfortable with NURBS modeling, and texturing NURBS models, go right ahead. It will give you a smoother and more rounded eyeball. I prefer not to complicate things with NURBS when polys will do just fine, and am guessing most of you feel the same, so I'm sticking with polys. This does however bring us to the topic of the SubSurface modifier and how it will affect your eyeball. When SubSurf is applied to a UV sphere such as our own, it causes the previously spherical shape to become slightly oblong. In other words, the eye will become nearsighted. This is barely noticeable, but it does happen, as a result of the way SubSurfing affects a UV sphere. You could create a UV sphere with more rings to ease this if it bothers you. It looks fine for our purposes though, to be honest. See the comparison in the animated GIF below.
There is one last issue to address with regard to using a polygon-based eyeball. That is the small triangles that persist on the poles of the eyeball. These stubborn tris will remain and you will find that they result in an ugly and unnatural pinched effect when a specular highlight appears over the center of the cornea. Adding a SubSurface modifier will not make them go away. This didn't become apparent until after I did some texturing work and test renders, but I want to point it out to you now, before we get into all that. (See examples below)
This can be remedied by adding more rings where those edges come together. Select only the edges in the very center of the cornea and Subdivide Smooth. Now deselect and again select the new innermost edges. Subdivide Smooth again. You can even do this a third time if you find it necessary. Rotate the model around in the viewport and do a couple of test renders to make sure the specular highlight doesn't reveal any artifacts.
Now repeat this process at the opposite pole of the eye (the optic nerve area).
We are now ready to begin texturing the eyeball.
In Edit Mode, we will define the seams for our eye. Select the edges you want to mark as seams and type Ctrl E, then choose Mark Seam from the menu.
With all of your mesh selected, type U to unwrap. We can now see our unwrapped UV layout in the UV/Image Editor window. (For older versions of Blender, you might need to select UV Face Select mode to unwrap, but it's better if you download the latest.)
Those two islands we see are the cornea and optic nerve area. We can move them out of our way by selecting any vertex on them and typing L to select all linked vertices. Then G to grab as usual.
Select a column of verts on the sclera region of our UV layout. Type W to bring up the Weld/Align menu. Choose Align X. This is how we will go about straightening this contorted shape into a usable guide to map our textures.
Grab and move your straightened column of verts over to the left.
Constraining to the X axis, by typing the "X" key after you grab, is a good habit to get into while straightening these out.
Straightening out all of these vertices into a usable grid shape will take you some time. It's one of the more tedious steps of this tutorial, but it's worth it in the end because having a rectangular grid will prove very helpful when we are texturing our eyeball. You'll want to use Blender's grid as a reference and just align the rows and columns to it exactly. Well, you can't get it exactly aligned, since there is no snap-to-grid feature, but you can eyeball it and everything will work out fine. The grid lines must be perfectly straight though, so always constrain to either the X or Y axis when moving anything. You can scale the whole thing up later, once each row and column is evenly spaced. Be sure to leave some space between your UV layout and the border of the layout area - don't "bleed" it to the edge or you will have texturing problems later.
[EDIT by nick_chang207]: You can align them perfectly; all you have to do is select all the rows and coloumns one by one, (you can use Alt + R) and then select the axis along which you want them to be aligned. For example, select the top column and then press 'S' to scale, then 'Y' to align it to the Y axis, and then '0' to align them. For the rows, do the same thing, only select the 'X' axis instead of the 'Y' axis this time. Its pretty easy this way.
[Edit by redset] If it's not clear, you can actually untangle this way too - simply Alt+RMB to select a row of edges, S Y 0 and Return (or left-click) to align them all, then G Y to move them up to a grid line. Repeat this for each row of edges, then work across the columns using the X key to align your scaling and movement to the X axis instead. You'll end up with a nice neat grid, and if you aligned them to gridlines you can just scale the entire island up to fill as much space as you need.
It's important to pay attention to which way the UV layout is facing. Chances are the top of the sclera region is actually what you will want to be the bottom. It doesn't technically matter which way it's facing, but you will probably want it to look intuitive when you are painting the textures. I had to rotate that piece 180 degrees to get the cornea pole on top and the optic nerve pole on the bottom.
[Edit by redset] Mine actually seemed to be the right way up - I found you could check by going to the 3D view (or having split windows so you can see the 3D and UV views at the same time) and making sure every vertex is selected, then holding shift and clicking to deselect a vertex on the model, close to the optic nerve or the cornea. Back in the UV view the vertex will disappear from your UV map, so you can work out how the map corresponds to the actual mesh surface. There might be an easier way to check but I'm new to this myself! (Just select all again to get the whole map back)
Once you're done, save your .blend file and then save your UV Face Layout. This is done in the Scripts Window: Scripts > UV > Save UV Face Layout. The "UV Image Export" dialog box will appear. I recommend choosing a size of 2048 pixels.
Preparing A Template For Texturing
Now launch your image editor and open the UV face layout you just saved. (You probably saved it as a .tga file, since that is Blender's default format for UV layouts) So we are now looking at a black and white UV grid. We want to get rid of the white regions so we can see through them to the layers below. The quickest way to do this is to set the blending mode to "multiply". If that works for you, go for it. Personally, I like my transparency to be represented by the checkered pattern, and for that we will need true alpha transparency. In Photoshop this can be done by going to the menu and choosing Select > Color Range. Using the eyedropper, click any white part of the image, set Fuzziness to zero, and click "OK".
Now delete the selected white regions by choosing Edit > Clear from the menu.
nooby note: The same actions can be done in the GIMP editor by going to menu, choose Select > By Color and click any white part to select the white area. Then go to menu again and choose Colors > Color to Alpha and click "OK".
another nooby note: In PhotoShop you can also modify the layer's blending options so that areas of white or black will become transparent: When you first open the image in photoshop it will be a single layer image, and the layer name will be 'background' - Double click it and give it a name like "UV-Grid". THEN select the "UV-Grid" layer, Right-Click -> "Blending Options", in the bottom area of the dialog set the top value for the slider on "Blend If -> This Layer" setting on grey to be a little lower (most likely 254). This means any values on "this layer" that are greater than 254 will be blended with the underlying layers. - Make sure you create your other layers BELOW this layer so the grid will always be on top.
One other element that will be useful to have in our template is a layer of markers that denote where the equator of the eye is, because what looks like the middle on the UV layout is not actually the middle. To find the middle, go back into Blender and count the rings of your eye mesh, starting at the seam of the cornea. Once you get to the equator, take note of how many rings it took to get there. Go back to your image editor and mark that area. You can mark it with a guide, or mark it with a coloring of some sort - as long as it's clear to you that it indicates the equator of the eye mesh. It may also be useful to mark the point where the transparency of the cornea should begin.
First Bump Map - The Sclera
Create a material for your eyeball. Then within that material create a texture. Name this texture something like "BumpMap(Procedural)". Set the texture type to clouds. A noise size of 0.25 with a noise depth of 2 or 3 is fine, and you can experiment with other values if you like. The other texture settings can be left at their defaults.
Now we are going to bake this procedural texture to get an image-based UV texture that we can edit in our paint program. Why? Because there is not an even level of bumpiness around the eyeball. The sclera has bumps, while the cornea doesn't. If your cornea was bumpy, your vision would be distorted. We want our 3D eyeball to accurately convey this subtle difference when light is reflected from the surface.
Before baking the texture, there are some parameters we must specify. In the materials panel click the Map To tab. The Color button is depressed by default, so you can leave it as is. Make sure this is the only depressed button. Then change the color to black.
Now go to the Material tab. Change the diffuse color to white and click the Shadeless button.
Note: In this particular case it doesn't actually matter which of these colors is set to white and which is set to black. The end result is basically the same, and you can always invert the image later.
Check the Material Preview window to make sure it looks right.
Time to bake your eye. Make sure your eyeball object is selected and go into UV Face Select Mode. Then split your screen and set one viewport to the UV/Image Editor. From the menu at the bottom of the UV/Image Editor, choose Image > New. Enter a name like "ScleraBumpBake" and set both the Width and Height to 2048 (to match your UV guide). Click "OK" and a new all-black image will appear behind the UV grid.
Go to Scene panel > Render > Bake tab and click the Textures button. Then set the margin to 10 and click the BAKE button. You will see the black image in the UV/Image Editor fill in with your bump texture. From the menu choose Image > Save As.
Now would also be a good time to save your .blend file.
(Where's the rest of this tutorial?)