Creature Eye Shader is available on the Unity Asset Store.


“My, what big eyes you have.”–Little Red Riding Hood

What eyeless creature lurks within the halls of your game? Give it eyes, yes, but what kind? Does it have the eyes of a snake, an octopus, or maybe a frog? Each are possible with this shader. It exposes nineteen parameters that will help you define just the right kind of eyes for your creature. Hopefully your creature is not dead yet, so you may want its eye(s) to move; an included script will help you avoid that vacant, soulless stare. There are two shaders–unlit and surface–depending on whether your creature abhors the light. So please enjoy the world with new eyes.

Features

  • Unlit and surface eye shader
  • Shader Parameters
    • Sclera, Iris, and Pupil parameters
      • Color
      • Radius
      • Squeeze
      • Angle
    • Eyelid and third eyelid
      • Color
      • Bias
      • Open
  • EyeMovement script
    • Random eye movement
    • Look at target
    • Random blinking
  • RandomizeShader script
    • Randomize certain shader parameters
  • ApplyPaletteToShader script
    • Apply colors to material
  • Semi-sphere model

Scenes

Eight demo scenes are included. Here are some animations of them.

Parameters

The eye shader exposes the following parameters that influence the eye’s look.

Sclera (eye white)

Sclera Color

The word “sclera” is the technical term for the “white of the eyes”.

Sclera Radius

The UV maps from [0, 1] an each axis, so the sclera radius is from [0, 0.5].

Sclera Squeeze

The eye can be squeezed from a circle into more of a lens shape.

Sclera Angle

By default the closed eye’s lid is along the x-axis. The sclera angle changes this.

Iris

Iris Color

The iris color is given here.

Iris Radius

The iris radius’ range is [0,1]. A radius of one will cause it to take up the whole eye.

Iris Squeeze

The iris squeeze works just like the sclera squeeze but it applies the squeeze in a different direction to make it look like cat eyes.

Iris Angle

Same as sclera angle but applies only to the iris and pupil.

Pupil

Pupil Color

The color of the pupil, usually black.

Pupil Radius

The pupil radius’ range is [0, 1]. A radius of one will cause it to take up the whole iris.

Pupil Position

This a 2D vector stored in a 4D vector. The first two values store the pupil’s (x, y) position mapped from [-1,1] where the origin (0,0) is the eye looking straight ahead.

Eyelid

Eyelid Color

The color of the eyelid.

Eyelid Bias

The eyelid may be offset such that it is lower or higher than the mid-line of the eye.

Eyelid Open

The eyelid open ranges from [0, 1]. A completely open eye is 1. A completely closed eye is 0.

Third eyelid (optional)

Third Eyelid Color

The color of the third eyelid. The alpha component determines the third eyelid’s opacity.

Third Eyelid Bias

The third eyelid ranges from [-1, 1], a -1 means when the third eyelid closes it’ll close to the left, 1 means to the right, and 0 means to the center.

Third Eyelid Open

The third eyelid open ranges from [0, 1]. A completely open eye is 1. A completely closed eye is 0.

Background (non-eye)

Background Color

Whatever is not the eye is drawn as the background color, unless “Clip background?” is set to true.

Clip background?

If “Clip background?” is set to true, any fragment that would have been drawn as a background will instead be clipped.

Surface Options

The surface shader exposes a few more parameters.

Glossiness

This controls how glossy the background and eyelid are. This property is ignored if “Use alpha as glosiness?” is turned on.

Eye Glossiness

This controls how glossy the sclera, iris, and pupil are. This property is ignored if “Use alpha as glosiness?” is turned on.

Use alpha as glossiness?

In the surface shader, there are two ways to set the glossiness: 1) Set the “Glossiness” and “Eye Glossiness” property in the material. However, if “Use alpha as smoothness?” is set to true, the alpha channel from each color is used as the glossiness of that part.

Acknowledgments

Many thanks to Owen Deery for his excellent article on his parametric eye shader.

Many thanks to Curtis Aube for providing me with a half-dome mesh that became the eye ball.

Don't miss the next article!