Coloring the Eye

If you followed the eye modeling tutorial, you should have a model of an eye that has the boring, plastic default gray material. If you haven’t modeled that eye, don’t worry; it’s right here. Feel free to download it if you need a starting point. The purpose of this tutorial is to make that eye look more like an actual eye and less like a gray ball.

Setting up a Materials screen for BI

When working with materials in Blender — particularly when rendering with BI (Blender Internal) — you find out very quickly that you often have to scroll the Properties editor or you frequently have to switch between different sections of the Properties editor. This fact is even more apparent when you start working with textures in BI (see Chapter 8 in Blender For Dummies, 3rd edition). What it comes down to is that the default screen layout is inadequate for working with materials. The best way to alleviate that problem is to create your own screen layout that shows you all the information you need all at once.

To start, I recommend that you set up this new screen from a fresh Blender scene, so either open Blender now or reload the startup file by choosing File→New. This way, after you set up this new screen, you can include it with your startup file and it will be available for you in all your future Blender sessions.

With your default scene loaded, go to the header at the top of the Blender window and use the Plus (+) button on the right of the Screen datablock to add a new screen layout. When you do so, not much will appear to change, aside from the screen name now showing as Default.001. Left-click the text field in the screen datablock and change the name of this new screen to Materials. Now you can actually edit the screen layout to suit your needs. I tend to like the layout shown here.

A new screen layout for working with materials in Blender.

To get this screen layout, use the following steps:

  1. Remove the Timeline at the bottom of the screen.

If you’re not sure how to split and join areas in Blender, have a look at this page in the Blender documentation (although that page currently mis-identifies windows, areas, and editors). You could also have a look at Chapter 2 in Blender For Dummies, 3rd edition.

  1. Vertically split the 3D View so that you have a narrow column on the left side of the window.

  2. Change your new area to a Properties editor (Shift+F7).

  3. Set your new Properties editor to display Material Properties.

  4. Split this new Properties editor horizontally, showing just enough space to see the material preview panel in the upper area.

This way, you can always see what your materials look like as you make adjustments in the lower Properties editor.

  1. Change the right-side Properties editor to show Texture Properties.

This step isn’t really necessary at this point, but it will be useful down the road.

  1. Switch back to the Default screen layout (Ctrl+Ctrl+) and save user settings to your startup file (Ctrl+U or File→Save Startup File).

Now, whenever you start Blender, you have a Materials screen that you can jump to for editing BI materials on a model.

At this point, you can load the eye .blend file (F1) and begin working on its materials. One note: Because the eye model was created before you made your custom Materials screen, if you simply double-click the .blend file and load it outright, you won’t see your Materials screen in the screens datablock. To get around this issue, look to the left region on the side of Blender’s File Browser. Disable the Load UI check box near the bottom of that region. After you do that, you can double-click the eye .blend file you want to load. Now you should be able to look in the Screens datablock and choose your custom Materials screen. Your Blender window should now appear something like the window shown in the following figure.

The eye model loaded in a custom Materials screen layout.

The easy part: Material slots

Now to play with materials! Specifically speaking, you need to create two materials for the eye: one for the cornea/sclera around the eye and another for the eye interior. This is true, whether you’re rendering with Cycles or BI.

Creating the cornea material

To create the cornea material for Cycles:

  1. Left-click the New button in the material datablock or Material Properties and name this material cornea.

The cornea and sclera wrap around the eye, so as a material, it should be transparent. You may want to preview your material changes in the 3D View by enabling Rendered viewport shading (Shift+Z).

  1. In the Surface panel, choose the Glass BSDF shader from the Surface drop-down menu.

The default settings should be fine. If things don’t look right, chances are good that your lighting is a bit off. Make sure any light objects in your scene are using multiple importance sampling.

To create the cornea material for BI:

  1. Left-click the New button in the material datablock of Material Properties and name this material cornea.

The cornea and sclera wrap around the eye, so the layer is transparent.

  1. Enable the Transparency check box in Material Properties and reduce the Alpha setting down to 0.500.

The material preview updates, but the 3D View has no apparent effect unless you’re previewing with Rendered viewport shading (Shift+Z).

  1. Go to Object Properties and enable the Transparency check box in the Display panel.

I like doing this in the right-hand Properties editor in the custom Materials screen created in the preceding section. The following figure highlights the controls for enabling transparency in the 3D View.

Enabling transparency in the 3D View.

  1. Return to Material Properties and make the following adjustments to your cornea material:

    • Diffuse Shader: Oren-Nayer
    • Diffuse Roughness: 0.300
    • Specular Shader: WardIso
    • Transparency Fresnel: 3.000
    • Options→Traceable: Disabled
    • Shadow→Cast Buffer Shadows: Disabled

The last two settings are particularly useful because by disabling them, you prevent your cornea from casting a shadow upon the interior of the eye. If later, when you render a character with these eyes, the eyes render in all black, chances are good that you forgot to disable these material settings.

Building a base material for the eye interior

After the cornea material is complete, you can work on the interior elements. Currently, the entire eye is the same transparent material as the cornea; that’s not likely what you want. In that case, you need to create a new material:

  1. Return to the top of Material Properties and add a new material slot by left-clicking the Plus (+) button next to the material list box.

This step creates a blank material slot.

  1. Left-click the New button in the material datablock to create a new material.

  2. Name your new material eye.

Now that you have a slot for your material, you need to set it up. If you’re rendering with Cycles, the default material with a white Diffuse BSDF shader will work just fine for the time-being. If you’re rendering with BI, make the following adjustments to your material in Material Properties:

  • Diffuse Color: White
  • Diffuse Intensity: 0.900
  • Diffuse Roughness: 0.500
  • Specular Shader: CookTorr
  • Transparency: Disabled
  • Transparency Alpha: 1.000
  • Transparency Fresnel: 0.000
  • Options→Traceable: Enabled
  • Shadow→Cast Buffer Shadows: Enabled

At this point, the preview images for your materials show look something like what’s shown here. On the left are material previews in Cycles and on the right are previews in BI.

The base material for your eye.

Assigning the base material to interior faces

Of course, although you created a new material for the eye’s interior, that material has not yet been assigned to any faces of your model.

  1. Tab into Edit mode and make sure that no faces are selected.

You can do so by pressing A until nothing is selected.

  1. Select all the linked faces for the cornea/sclera by hovering your mouse on the exterior faces of the mesh and pressing L.

  2. Hide the selected faces (H) and then select all visible faces (A).

The vertices of your interior eye should all be selected.

  1. In the Context section of Material Properties, click the Assign button to assign the eye material to the selected faces.

  2. Tab back into Object mode.

Your results should appear like the image. On the left is the eye in Cycles and on the right is the eye in BI.

The eye model with a transparent material wrapped around a solid white interior material.

Creating a pupil

Now you need to create a material slot for the eye’s pupil. Using the same basic steps described in the earlier section, “Building a base material for the eye interior,” create a new material slot for your pupil.

  1. Left-click the Plus (+) button next to the material list box in Material Properties.

  2. Left-click the New button in the material datablock to create a new material.

  3. Name your new material pupil.

  4. Make adjustments to your pupil material.

For a Cycles material: * Surface shader: Diffuse BSDF * Diffuse Color: Black

For a BI material: * Diffuse Color: Black * Shading→Shadeless: Enable

  1. Use the same basic steps described earlier in the “Assigning the base material to interior faces” section to assign your new pupil material to the central faces of the eye.

When you finish, your result should appear like this (left is Cycles and right is BI).

The eye now has a pupil.

From here, you have two options. The easiest thing would be to create another material slot for the eye’s iris. And if you’re not too worried about detail, that could very easily be enough. However, if you want a bit more detail, you may want to use Blender’s Vertex Paint feature to give you colors with more subtle variations than just straight material slots can get you.

Getting more detailed with Vertex Paint

In this section, you can get more detailed and subtle color results for the main body of the eye. Before you bolt face-first into Vertex Paint mode, you should first make sure that your painting gets rendered:

  • For rendering in Cycles:

    1. In the Vertex Colors panel of Mesh Properties, left-click the Plus (+) button next to the list box to add a new vertex color layer.

    Name the layer something logical, like eye or iris.

    1. In the Surface panel of Material Properties, left-click the connector button (its icon is a small circular dot) to the right of the color swatch and choose Attribute from the menu that appears.

    2. In the Name field, type in the name of your vertex color layer (eye or iris, depending on what you did in Step 1).

  • For rendering in BI:

    1. Select the eye material in the list box at the top of Material Properties.

    2. Enable the Vertex Color Paint check box in the Options panel.

Now you’re ready to start painting.

Painting the iris and the back of the eye

If you go to Vertex Paint mode (V) in the 3D View right now, not much appears to change. This setup isn’t a particularly nice way to paint your vertices. You only have access to painting the exterior cornea/sclera of the eye. The interior parts of the eye model are completely obscured and inaccessible. Fortunately, there’s a way around this issue. Left-click the Face Selection Masking for Painting button in the 3D View’s header. Upon doing so, you see a shaded version of your interior eye model with light wireframe lines drawn over the surface.

Tip

You may be wondering why the exterior faces of the eye model disappeared. Well, earlier in this practical example, you went into Edit mode, selected the external faces (L), and hid them (H). When you’re in Vertex Paint mode and you enable the Face Selection Masking button, Blender shows only the faces that are visible in Edit mode. It’s a pretty handy trick for Blender’s various paint modes in the 3D View. Of course, if you still see the faces of your eye’s exterior, you can select those faces (L) and hide them (H) right from Vertex Paint mode.

Tip

Another handy tip to keep in mind is that any faces you selected in Edit mode persist in Vertex Paint mode when you have the Face Selection Masking button enabled. Although most of Blender’s selection tools (right-click, border select, circle select, lasso select) work in Vertex Paint mode with Face Selection Masking, some of the useful selection operations, like loop select (Alt+right-click), don’t work. If you need to select a loop, you can quickly tab into Edit mode, do your loop selection, and tab back out to Vertex Paint mode.

In fact, to select the faces that make up the eye’s iris, loop selecting is exactly what I recommend you do:

  1. From Vertex Paint mode with Face Selection Masking, Tab to Edit mode.

  2. Use Blender’s loop select operation (Alt+right-click) to select the faces that make up the eye’s iris.

  3. Tab back into Vertex Paint mode and paint your iris using the vertex paint tools.

When you do your vertex painting, it affects only the currently selected faces.

  1. Invert your face selection (Ctrl+I).

You should have everything other than the iris selected. You may also want to deselect the faces of the pupil, but because they’re assigned to another material, that’s really not necessary.

  1. Tab back into Vertex Paint mode to paint red and pink tones around the back of the eye.

When you finish, the result should look something like the following figure.

Using Vertex Paint mode to paint details for the eye.

Seeing your vertex colors in the 3D View

If you pop back into Object mode, your freshly painted vertex colors may not appear on your model. Don’t worry, though, they’re definitely there. To see your colors in the 3D View, you need to adjust your display settings. The first thing you need to do is switch your 3D View to the Textured viewport shading (Alt+Z). By default, the results aren’t particularly pleasant. The transparency of your cornea is no longer apparent, and the front of the eye is probably completely darkened. Worse, if you’re rendering with Cycles, there’s virtually no change between Solid and Textured viewport shading

This ugliness in BI is actually caused by two things: your display settings for the 3D View and your light placement in your scene. To deal with the former, bring up the Properties region of the 3D View (N) and go down to the Display panel. This panel contains a drop-down menu labeled Shading. By default, this menu is set to Multitexture. Left-click the menu and choose GLSL. Assuming that you have a suitably modern video card, the results in your 3D View should already be improved. Of course, the front of the eye is still dark.

To deal with the darkness at the front of the eye, simply select the lamp in your scene, grab it (G), and move it so that it’s in front of the eye. Moving the lamp should illuminate the iris and pupil of the eye model. If the eye is still too dark for you, you can duplicate the lamp (Shift+D) a couple times and move those duplicated lamps around your scene to more clearly light the scene. Chapter 9 has more detailed information about lighting in Blender. When you’re satisfied, you can hit F12 and kick out a quick render or use Rendered viewport shading (Shift+Z) to see what it looks like.

Remember

Unfortunately, when you render with Cycles, there’s currently no way to use GLSL for the viewport display, so you’re kind of stuck with two choices for seeing your vertex painting: use Vertex Paint mode or use Rendered viewport shading (Shift+Z). The former isn’t exactly ideal if you want to have a good idea of what your finished eye looks like. Fortunately, Rendered viewport shading in Cycles is pretty fast, so that’s the method I would recommend.

The following figure shows an example of what the eye might look like in the 3D View (Cycles on the left, BI with GLSL on the right).

The eye, colored with material slots and vertex colors (on the left is Cycles with Rendered viewport shading and on the right is BI with GLSL Textured viewport shading).

As with the modeling tutorial, keep this file around. You can use it for the unwrapping and texturing tutorial.

Like this tutorial? It pairs really nicely with my book, Blender For Dummies, 3rd edition. It’s available anywhere books are sold. Thanks!