Blog of Rob Galanakis (@robgalanakis)

Eye

DOWNLOAD

The eye shader is designed around two philosophies seemingly at odds: visual fidelity, and variation with low overhead. The same eye shader and set of textures provides 4 eye “types” with an infinite number of colors. Adding a single 256×256 RGBA texture provides a whole new set of 4 eye types. So, instead of having 10 eye textures for 100 characters and having repeating eyes, the same 10 textures can produce 40 100% unique eyes, and the rest of them with 100% unique eye colours.

The variation is achieved with an RGB texture that does not control diffuse colour, but are masks for externally-set diffuse colours. The inner iris, outer iris, and veins all have a unique colour that can be set differently for every single eye with absolutely no hit whatsoever to performance. On top of this “colour comp” is applied one of four “overlay” channels from an RGBA texture to give finer detail.

Visual fidelity is handled in two parts. The first, is the cornea (the whites of the eye). The ambient colour controls the overall reflectivity of the unlit areas of the eye. There is a variable for biasing the diffuse lighting. A normal map creates the “bulge” of the cornea over the front of the eye and iris. Most importantly, the specular highlights are multiplied by a reflection map, which breaks up the specular highlight. Because eyes are 100% reflective, they clearly reflect the shape of their light source. Thus, the traditional round shape of the specular highlight looks “fake.” The broad specular broken up by the reflection map (which has brightness and contrast controls) approximates an image-based lighting approach very cheaply.

The second part is the iris. The iris’ specular highlight is broad, and takes the colour of the iris. The inverted normal map is used to approximate the “inverted hemisphere” of the iris, that recedes from the eyeball’s spherical surface.

rgbTexture: R channel holds the vein color mask, G holds the inner iris colour mask, B holds the outer iris colour mask.

overlayTexture: Each channel (RGBA) holds an overlay texture that is multiplied over the eye’s base colour (after the application of the eye colour variables to the rgbTexture masks).

normalTexture: Should have a “bulge” out in the iris area.

reflTexture: The cube map that is the ambient reflection and breaks up the specular highlight. For best results, should have areas of strong contrast, and irregular shapes (such as, a forest).

Leave a Reply