Eye Shader (Pre-3.6)

Overview

The eye shader is a specialized shader for rendering eyes. Eyes are very complex not only in shading but also in composition, therefore their shading/look cannot be achieved via regular shading methods.

Eye Params

Shader Params

Description

Shader gen option

Cornea Opacity

Sets the opacity of the cornea.

Default

Glint multiplier

Sets the strength of the glint highlight.

Default

Iris color

Sets the color of the eye's iris.

Default

Iris depth

Sets the depth of the iris.

Default

Iris scattering

Amount of light scattering inside the iris.

Default

Pupil dilation

Sets the default amount of dilation for the pupil.

Default

Pupil dilation dynamic

Sets the strength of dynamic pupil dilation.

Default

Pupil position X

Sets the horizontal position in UV space (X, or U) of the center of the pupil.

Default

Pupil position Y

Sets the vertical position in UV space (Y, or V) of the center of the pupil.

Default

Depth bias scale

Sets the depth bias of the overlay mesh to avoid clipping with the eyes.

Eye overlay

Occlusion strength

Sets the strength of ambient occlusion for the overlay.

Eye overlay

Basic information and limitations

  • The new shader uses "Iris Parallax Mapping" by default. The old alpha-blended method has been deprecated (doesn't work with deferred lighting).
  • The setup process has been modified from the previous versions of the shader, therefore making old assets incompatible with the new shader (luckily, fixing the assets requires very little work).
  • Self shadowing has been removed due to artist feedback.
  • The new shader was designed with merged textures in mind (character head texture contains eyes and overlay in the same texture).

Eye "component" breakdown

An eye is made of several "components". The most relevant ones in this case are the sclera (white area), iris (where eye color comes from), pupil (the dark spot in middle), and the eye cornea (the "windshield" of the iris).


Simplified eye structure

The eye shader simulates these components using various techniques in a single draw call.

Mesh setup

The first step is to setup the mesh for use with the eye shader. There are 3 meshes used to create a believable eye.

  • The eye ball: Rather simple. Just a small hemisphere with the usual texture maps.
  • The eye overlay: A small mesh that covers the gap between the eye lids that is used for ambient occlusion.
  • The eye lashes: A simple mesh with an alpha blended eye lash texture applied.

This process is relatively straightforward. The overlay should be correctly skinned to move with the eyelids or modeled in such a way that moving eyelids won't cause cracks in the overlay.

Texture setup

The texture setup is the most important part of the entire shader. The textures should follow these guidelines:

  • The specular map is used for the iris mask (in alpha) and the iris scatter texture.
    • This is for merged face/eye textures. A face specular texture should have gloss in the alpha channel and thus can be used for the iris mask.
    • Currently the specular map has no effect on the actual specular term. This may change in the future.
  • The diffuse map is used as the main source of color.
    • For the overlay, the red channel controls the ambient occlusion and the green channel controls the overlay specular.

Eye texture examples


Overlay Red Channel

Overlay Green Channel

Merged result

To update old assets to use the new shader:

  • Move the iris mask to the alpha of the specular texture.
  • Invert the iris mask color.

Using the Eye Shader

The Eye Shader

The eye shader has various parameters to control the look of the eye.

Cornea
  • Cornea opacity: Sets the opacity of the cornea around the iris. Can be used to weaken the reflection around the iris.

Zero opacity

Full opacity

Glint
  • Glint multiplier: Sets the strength of the glint specular highlight.

No glint highlight

With glint highlight

Iris
  • Iris color: Allows dynamic modification of the iris color.

  • Iris depth: Sets the depth of the iris parallax effect.

No parallax

With parallax

  • Iris scattering: Sets the strength of scattering in the iris.

No scattering

With scattering

Pupil
  • Pupil dilation: Strength of default dilation for the pupil.
  • Pupil dilation dynamic: Strength of dynamic pupil dilation caused by varying light conditions.

Pupil under bright light conditions

Pupil under low light conditions

  • Pupil position X/Y: Sets the 2d position of the pupil in texture space (XY = UV).

The Overlay Shader

The overlay shader is simple but very important. It's main purpose is to ground the eyes into the character and to give it a natural look. It contains but 2 unique settings.

  • Depth bias scale: Prevents Z-Fighting artifacts with the eye mesh by biasing it's Z value.
  • Occlusion strength: Sets the strength of ambient occlusion.

No ambient occlusion

With ambient occlusion