# Blender 3D: Noob to Pro/Procedural Eyeball

| previous module: "Creating Pixar-looking eyes in Blender" | • Table of Contents • Glossary | next module: "Putting It All Together: A Dragon!" |
Level: intermediate
Building a better (procedural) eyeball! Originally created by Jon McKay (Ammusionist) and posted on blenderartists.org/forum
The end result of this tutorial is an eyeball that fulfills the following requirements:
* Single mesh
** I wanted to be able to append a single object into any project.
* Procedural Textures
** I didn't want to have to rely on image maps that could get lost.
* Versatile
** One single model to be used for any type of character, be it human, alien or whatever.
* Easy
** Any effects needed to be quickly accessible. I don't want to be wasting time faffing around with colour-band settings at the texture level
* Impressive
** This sucker needs to look good any way it goes.
* One other thing I really wanted was the iris musculature to follow the pupil dilation!
An old and different Tutorial:

## Creating the Mesh

The objective here is to make a great looking eyeball. That means it may not be anatomically perfect, but there are some things we need to take into account: The eye should consist of a white (white bit with veins); an iris (coloured bit); a pupil (black but in the centre of the iris) and a cornea (clear bit surrounding the whole eye). These may not be absolutely correct, but these are how I'm referring to the pieces of the eye.
* Start with a ball: Go to a front view ( 1KEY ) and create a UV sphere. 32 Rings and 32 segments should be sufficient. It'll give us plenty of smoothness and enough verts to work with when we create shapes.
* Click on "Align to view"
* This sphere will become the coloured parts of the eye, but we also need a second sphere for the cornea. Use the Z key to switch to a wireframe view (if you're not already there). Hit the A key a couple of times to ensure all points are selected then Shift + D to duplicate the sphere.
* Press S key to scale and scale the second sphere to slightly larger than the first. (Hint: Hold Shift while scaling for fine adjustment) or you could also enter a value, 1.01.
* Now that we have a nice confusing mesh, we're going to make our life easier. We're going to hide the outer bit for the moment. Hit the H key.
* Noob Note: Don't panic like I did the first time I accidentally hit H , you can bring it all back with Alt + H . (Note: In blender Alt + some key often reverses the effect of pressing the key in the first place!)
* OK Now to create the basic mesh for the inner part. Basically, we need to make a concave iris/pupil section.
* Make sure you’re in Orthographic view.
* Switch to a side view and use the Border Select ( B ) to select the first 4 rings and the tip. Now we're going to flatten these. Press S for scale Y for Y axis only and 0KEY for scale-to zero.
For more realistic eyes you can also grab the inner 3 rings + the tip a bit inwards the eye.
Noob Note: It is also possible to flatten the rings in a way that leaves the last ring in place and moving the rings later is not necessary. Before you flatten those 4 rings and the tip of the sphere place your 3D cursor in the plane where the last ring involved in scaling operation lies (use border select to select only the fourth ring, press Shift + S , and select "Cursor to Selected"). Then set the pivot point to "3D Cursor". Finally proceed like instructed above by selecting all rings to be flattened and scaling them to 0 in Y direction. This time the outermost ring will stay in place. Do not forget to set the pivot point back to the default option "Median Point". You may return the 3D cursor to the center by pressing Shift + C .
* Last, grab them along the Y-axis to the eye till it's round again.
* Now for the cornea. It's not perfectly spherical; it bulges slightly at the front. We're going to use the Proportional Editing tool.
* First, we need to un-hide the cornea. Hit Alt-H to make it visible.
* Click the O-Key, this will activate proportional editing, click on "Connected" in the 3D view header at the settings for Proportional editing.
* Select the type of falloff: “Sphere Falloff”
* Press A-Key a couple of times again to make sure no points are selected, switch to a side view (Keypad-3) and right click just to the left of the front-most point. We just want to select the tip vertex.
* Now comes some fun. We want to drag that point away from the eye in the y axis, so press “G” for grab and “Y” for Y axis. As you move the vertex, you'll see a circle that defines the influence of the proportional editing. Adjust it so it is as the height of the whole iris and drag it out until it looks right.
* First, switch off Proportional editing.
* Select from center the tip and the first 4 Loops.
* Then Hit Ekey and Ykey then drag out a bit 'till it's good.
* To clean the model up, we're going to apply a subdivision surface modifier and some smoothing.
* Go to Modifiers in the Properties Header and hit new and choose "Subdivision Surface" choose view: 2.
* Hit Tab to switch to Object mode and hit the "Set Smooth" button in the Link and Materials panel.
* Now would be a good time to save your work before we go on to textures.

## Adding the Textures

You're going to need multiple materials on this mesh. It's possible to apply materials to selected faces.
* Press A a couple of times to ensure nothing is selected.
* Press Z to switch off wireframe; this will be easier without it.
* Place the mouse pointer in the centre of one of the faces on the outside layer of the eye and press “L” to select linked faces. If you get a message saying “Nothing Indicated” try positioning the pointer on a different face and try again.
* Once the outside section is selected, go to “Materials” in the Properties Header, click “+”. Click “Assign” to assign the outside faces to Material.001.
* Now the inside.
* Hide the outside faces (H-Key). We'll assign the rest from the eye. If a face is already assigned to a material and you assign it to another, it just switches material.
* Press A to select all and, as above, click “+” then click “Assign” so it is assigned to Material.002.
* Now for the iris and pupil.
* Hit A to deselect all.
* Switch to a front view and zoom in. Hit “C” to enable circle select and select the central faces plus one ring out. You can control the size of the selector by rotating your mouse wheel.
* Again, create a “+” material index and “Assign” the pupil faces to it.
* Finally, click Akey to deselect all and use circle select again to select the remaining faces on the iris. Assign them to a new material.
* Now we're ready to make the materials.

### Cornea Material

* Switch to object mode (Tab). Go to Material.001.
We'll start with the simplest texture first. The cornea is basically just colourless and transparent. This is because some lighting conditions make the eye under the cornea difficult to see. Go to the shading buttons (F5)
* Locate the “Transparency” control. Set this on. This means as we go we'll be able to see through the cornea. Note that we're using Z-Transparency instead of Raytrace. And set Alpha to ".2"
* Diffuse at white and intensity is 0.1.
* Under Specular CookTor is used 1 and Hardness is 333.
* Under Mirror, Click on, and set to 0.4, Depth is 3
* Unclick the 'Traceable' setting under Options
* And Under Shadow unclick "Cast"

### White Material

The white of the eye's a little trickier. The material here includes some red veins that can be seen at the side of the eye, but not from the front. This can be done with two textures, but there's a cheat we can use.
First, the veins:
Switch to Material.002.
Go to the texture Properties aside of the from the Material:
Make a new texture.
Use a marble texture, and copy these settings.
* Under color choose Ramp.
* The first point is "0": Pos=0; R=1, G=0.0, B=0.0; A=1;
* Click on the second point, The second point is "1": Pos=0.340; R=1, G=1, B=1; A=1;
* Under the Marble tab: Sharper, Sin, and under "noise", hard are clicked;
* Size=2; NoiseDepth=10; Turbulence=26.04;
* And set under mapping "Coordinates" to "Generated". And "projection" to "sphere" or "Flat".
The two colour band items are shown here separately. This makes a nice marble texture that will evenly cover the eyeball. So how to hide it from the front of the ball? Another colour band trick, but this time in the material itself.
Here they are in all their glory.
* Under the material tab, Diffuse is white and intensity is 1;
* Check Ramp, 0: Pos=0.533; R=1, G=1, B=1; A=0; Input is Shader;
* 1: Pos=0.544; R=1, G=1, B=1; A=1; Input is Normal;
The colour band items are both white with one alpha 0.0 and one alpha 1.0. As you can see they are very close together to give a fairly clear line that the veins will stop at. The input setting for the band is set to “Normal” this means the left hand side of the band refers to faces that are parallel to the camera view and the right is faces that are facing directly towards the camera.
There's also some colour band fun to be had with the pupil material.

### Pupil Material

I wanted a nice black texture, but I also wanted to get a red-eye effect if a light is shone directly at it from behind the camera. Why? I guess just because I can, and now so can you!
As before move to Material.003.
There are no textures in this one. It's basically black and a little reflective with a nice hard specular.
* Diffuse is Black, presumably with an Intensity of 1
* Specular is white with an Intensity of 0.6 and a Hardness of 300;
* Under Mirror reflectivity is 0.1;
If you want to have the red-eye effect, have a good look at the colour band settings though! (Not Necessary, and maybe not wanted by everyone)
* Check Ramp.
* 0: Pos=0.970; R=0, G=0, B=0, A=0;
* The second is fully red (with no blue or green). We want the red-eye to respond to light not angle like the white of the eye.
* 1: Pos=1; R=1, G=0, B=0, A=1; Input: Energy;
Now the bit you've all been waiting for – the iris!

### Iris UV Map

Save your work and grab a cup of coffee for this part. It's a little involved.
We need the texture to stay glued to the mesh irrespective of the shape of the mesh. This gives the effect of the muscles in the iris expanding and contracting. In a nutshell, we're going to UV map a procedural texture to a single part of the mesh.
OK, here we go. Switch material.004. You'll need to be able to see both 3D view and UV/Image editor. This can be achieved by splitting windows, if you don't know anymore how to do this read the "Blender Windowing System" module again. Noob note: If you rendered the image of the eye you will see the rendered image, we want an empty grid. So click the "X" in the Datablock (Image) choose-section in the UV/Image editor Header.
Make sure the window is displaying a front view (Keypad-1) this will be important when we unwrap the bit we're going to use.
Change the 3D view to edit mode en Face select mode.
* Hide the outside (cornea) as done before.
* Go to Material.004 and click on "Select" right of "Assign", this will select the to the material assigned faces. We will unwrap the faces to place our texture.
* You can use these properties for the iris material:
* Diffuse: black but with an intensity of 1
* Specular: Intensity: 0
* Now search in the tool shelf for the Shading/UV's tab, you will find there the "Unwrap" button under "UVs".
* Click it and select "Unwrap". The unwrap tool, is a tool which you can position a texture. You can allocate the places in the texture to the mesh by positioning the unwrapped faces in a grid. The texture can be an image or another texture and will be used at the places, that are described in the unwrapped image in the "UV/Image editor"
* Zoom in 'till it's placed exactly to the outer edge the "UV/image editor" window.
* The image window should now contain a nice even circle of dots. If they aren't selected anymore, put the cursor in the "UV/Image editor" and press “A” to select all the points. Now select each ring in turn using Alt-Shift, starting from the innermost, and scale them until they cover from the centre to the outside of the image grid as shown. (This won't affect the mesh)
Now we've got a map, lets get a texture. In the 3D view "Tab" to object mode for the next part. If the UV/Image editor is in your way you can merge the two windows. If you don't know anymore how to do this read the "Blender Windowing System" module again.

### Iris Texture

Firstly, a texture to control the colour blend across the iris. Generally it starts on the outer edge dark and gets lighter as it moves to the centre. Sounds like a job for the blend texture.
* Create a new texture for Material.004 at the Texture Properties in the Properties Header. It will be called "Texture.001".
* Change Type to Blend.
* create a second texture with type: Clouds
The texture itself is fairly straight forward, but again, the colour band is where the magic happens.
There are two stops in the colour band. Note the alpha values. This blend texture is meant to tint the iris texture so it's lighter in the centre and darker in the outside.
We make a Blend texture and a clouds texture (yes clouds)
Now for that iris texture:
Blend texture:
The blend texture is applied to the UV map input. The green colour is used as a lighten mix to tint the iris near the centre.
* Select Ramp,
* (Blue) 0: pos: 0, play with the color settings and set alpha to 1
* (Green) 1: pos: 0.009, play with the color settings and set alpha to 0.89
* set progression to Spherical
* Set mapping to Coordinates: UV, Projection: Flat
Now you've got color
Clouds texture:
The colour band points are black with alpha 0 and white with alpha 1.
* 0: pos: 0, black with alpha: 0
* 1: pos: 0.737, black with alpha: 1
* Under Clouds: Grayscale, Noise: Hard
* size: 0.4, depth: 2
* here is (together with the UV mapping) the magic of the lines: Mapping Coordinates: UV, Projection: Flat
* Important: Size X: 0.01, Y: 5
* Under influence - Geometry - Normal: 1
This texture is applied to UV again and. This makes some small shadows in the iris when the light is from the side. Add some lights and have a look at your eyeball so far.

## Pupil Dilation

We're going to use shape keys to create the pupil effects.
We're going to create a normal eye and a cat's eye. Fortunately, the fully dilated eye is the same in both cases so that's going to be our shape key basis.
Noob Note: note that you can only set a "Shape key" in object mode.
* Go to Object Mode and go to the "Shape Keys" properties in the "Object data" (The triangle one) context in the "properties" header.
* Click “Add Shape Key” to create the "basis".
* Make 3 extra Shape keys. (Don't make a shape key after editing, because you will change the previous keyframe and that is not the intention)
* Go to "edit mode" and click on Shape Key 1.
* Use circle select, Alt+Shift of de Select button in Material to select just the first 2 loops en the tip (pupil) in vertex select mode.
* Now scale this to the next loop, select the latter and scale to just before the edge of the iris (This gives a very wide pupil). It has to be as wide as possible because you can adjust how wide you want it in the shape key section. It is just a maximum so you can simply make an animation.
* Change the name to “Wide Pupil Contract”
* Just because you may also need it make a very little pupil (with shape key 2). Call it (Little Pupil).
Use the value slider in "Object mode", also set Viewport shading to Rendered (so you can see how it will be when rendered), To increase the shape of the pupil with "Wide pupil Contract" and make it smaller with "Little pupil" you can use them at the same time also (and much more if preferred).
Now switch back to object mode and try the shape key sliders out. Pretty neat huh?
* Let's make a cat's eye now. Change the name of Shape Key 3 to -”Cat Pupil”.
* Use the same method as before to scale the edge loops. As you scale, restrict your scaling to the X axis (That is “S” then “X”). You should end up with a shape key tiny but medium long.
That's pretty much it. Try some other things to practise with this.
Set the Camera and lightning.
Note: Due to the settings you've done in the material of the white of the eye, you have to position the camera in front of the eye. Because the white of the eye that overrules the vein-texture is a white spot in the middle of the camera and that has to be placed in the middle of the eye around the iris.
Don't forget to save – and enjoy!
| previous module: "Creating Pixar-looking eyes in Blender" | • Table of Contents • Glossary | next module: "Putting It All Together: A Dragon!" |