The Quick Eyeball Tutorial

Creating eyeballs for CG characters is one of the most important aspects of their design. The eyes give life to a character; no matter how good your animation is "dead" eyes will always make a character look doll-like. This tutorial will hopefully give you some insights into a few techniques you can use to make believable eyes. I have used Maya for this tutorial though the principles it explores can be applied in most 3D applications. For this test I am going to attempt to replace an eyeball in a photo with a CG one. Due to the lack of willing models this will have to be me hence the slightly shakey photos as I have to hold the camera as I take the picture and of course I can't see what I'm taking. First I take a macro photo of my eye with my digital camera.

Macro photo

My little digital point and shoot camera comes with a macro mode. It isn't as advanced as many more modern cameras but it is enough to make the image you see here. I tried to open my eyes wide enough that I could see the whole iris in the picture. It would be much easier to do this if you were taking a photo of someone else but this self-portrait will have to suffice for this test. You can immediately see that there are many reflections on the eye's surface. These are undesireable for the texture map we are eventually going to produce so we first paint these out.

Paint fixed photo

A little paint work removes the reflections leaving us with a diffuse iris. In addition to painting out the reflections I also paint out everything surrounding the iris so I end up with the diffuse iris on a pure white background. Here you can see the half-way stage of a diffuse iris but before I painted the rest of the photo out. We will project the finished texture map onto our eye surface later but let's look at the geometry required to build an eye.

A NURBS sphere

For this tutorial the eye will be made up of 2 NURBS surfaces, one for the underlying surface such as the white area, the blood vessels on the surface, the iris and the pupil and a second surface which will be reflective and highly transparent. This will define the lens and the wet surface over the rest of the eye. To the left is a NURBS sphere into which I have inserted some isoparms to better define the areas that will form the pupil and iris. This will form the basis of the underlying surface.

Deforming the sphere

Here you can see that I've selected the control vertices for the pupil and pushed them inside the eye ball. I have also selected the iris CVs and also pushed them a little so that they form a concave surface on the eye. This is important as the lens has to stand proud of this area and the iris does indeed form this shape. Now we need to model the shiny transparent surface.

The second, outer surface

Using the same techniques of adding isoparms and then pulling CVs I create a second surface from another NURBS sphere. Here in the side view you can see that the outer sphere shape is fractionally larger than the underlying surface. This ensures that this new surface is always on top of the underlying surface. You can also see how I've pulled the CVs to form the lens as a "bubble" on the surface of the eye, exactly as a real eye does. Make sure you set this surface not to cast shadows. If you don't you'll get strange shadowing artifacts on the eye surface underneath. For the time being hide the lens surface as we need to concentrate on shading the underlying eye geometry first.

Projecting the eye texture

Assign a shader to the underlying eye surface and attach the painted eye diffuse image onto the surface. It is important to project this map rather than using UV mapping. Using the texture projection controls move the image around till it lines up with the "crater" you've modelled for the iris. Also make sure that the pupil area matches up with the map. If it doesn't you can pull the CVs that define the pupil hole until they do. When you're happy with the line-up of map and geometry you can convert the projected texture to a UV map.

Converting projection to UV mapping

Here you can see that I've selected the shape node of the eye geometry and the projection node of the map in the multilister. Now select the convert to file texture option in the multilister and make a UV map of 1024x1024. This resultant UV texture should be loaded into your paint package. Here you'll notice that there's an iris and pupil mapped around each pole of the geometry. This is because the projection goes through the geometry and thus projects on both sides. It is a simple matter to paint out the the iris that appears on the back of the eye ball. This process is illustrated below. The image on the left is the UV texture created by Maya and that on the right is the same image after I've painted out the iris that was projected onto the back of the eyeball. You can see how the UV mapping wraps the image round the geometry leaving us with a very stripy image. This map when reapplied to the geometry will give us a white eyeball with and iris and pupil. We can now paint more detail onto the eye surface.

The complete diffuse map

I've added some more colouration to the eye's surface in the form of veins. I've painted this on top of the UV-layout map we made in the last step. We then create a Phong E shader with this image mapped as the diffuse colouration. We now need to paint some more maps to control the surface a little more.

Eye specular gain map

Here is a map where the iris area is white and the rest of the eye is black. This is mapped into the specularity values for the surface so that when light catches the iris area it has a slightly irridescent quality. The rest of the eye is unaffected by specularity. All the glints will be added by the other surface. All that is now needed is a bump map to define the veins and the iris crinkles of the eye.

Bump map for the eye surface

The bump map here has the vein layer form the diffuse map added to an extra layer which adds the crinkles to the iris. This helps the irridescence effect and is not technically what an actual eye does but it gives us the effect that we're looking for. These crinkles can be painted as horizontal lines as the UV texture mapping will make them radiate out from the pupil. This makes it easier to draw in your paint package. Now we can plug these into the Phong E shader that we previously attached to the eye surface.

The eye surface shader network

Here you can see how the maps have been plumbed into the shading network. Note that the eye diffuse colour has been blended with white for the specular colour. I usually add some translucence to the shader to account for the light bouncing around the eye both within and without. This value should be adjusted on a shot by shot basis. Now we can turn our attention to the lens and wet eye surface.

The eye lens shader

This shader network is also a Phong E shader. The most important element to add to the basic shader is fresnel falloff for transparency and reflection attenuation. Fresnel effects describe the way that an object at a more glancing angle is more reflective than at a facing angle. In mathematics this is derived as the dot product of the normalized incident vector (the direction the camera is looking in) and the surface normal. In Maya this value can simply be obtained from the samplerInfo utility which has a parameter called "facing ratio". I pipe this facing ratio value into the U parameter of a U direction ramp. This enables me to remap the facing ratio values in a more user controllable way to define visually how the reflection and transparency fall off. You can also see that I've added a reflection map and a bump map to this shader. Let's take a look at the lens bump map.

The eye lens bump map

I base the lens bump on a fractal pattern as the eye's surface is not as perfectly smooth as is sometimes assumed and it helps break up the specular highlights in an intersting way. I then add the vein map again. This makes the veins appear to stand slightly proud of the surface. You can particularly notice this effect in Gollum's eyes in the Lord of The Rings movies. We can now examine the finished shader.

The eye shader parameters

Here you can see some of the other settings I've used in defining the lens shader and see where the maps and facing ratio controls have been attached. You can see the effects of the fresnel on the transparency on the swatch. The eye apprears more opaque towards the glancing angle. I feel this adds a little solidity to the eye. The eye is now complete. We can throw a few lights onto it and have a look at what the completed eye looks like now.

The first render

This is the first render of the eye. As you can see some of the bump values are bit extreme and the specularity and reflection are a bit out of hand. We can adjust these settings and others to taste once we put the CG eye into the plate. Having played with the settings in both the shaders for half an hour or so I was able light and render the eye and then composite it into the photograph below.

The CG eye composited into a photo

Here is another nasty self-portrait I've been forced to use as a back plate due to the lack of volunteers among my friends to have their picture taken for this tutorial. I've composited one CG eye into this plate and left the other real eye alone. I'll leave you to guess which is which.

A Few Parting Thoughts

I hope this tutorial has given you some new approaches to creating CG eyes. I deliberately haven't made this a step-by-step tutorial as this would take too long due to the number of elements involved. I hope there's enough information for you to begin tackling this problem in a better way than perhaps you have in the past. An additional step you could take would be to add another surface within the eye to create the red-eye retina effects which we often see in photos. Some animals have a layer called the tapetum lucidum on the retina which reflects light back from within the eye. This is why a cat's eyes are so bright at night when they pass in front of a light source. Humans do not have a tapetum lucidum, the red we see in bad flash photos is the surface of the retina itself.

This is a very simplistic approach to doing eyes in CG, it's probably the very least you could get away with. To produce better results you would need to consider sub-surface scattering for the eyeball and refraction effects through the eye lens. I'll leave it there for this tutorial and good luck with your CG eyes.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.