NavigateGo to homepage

Portfolio

NavigateBrowse blog

Published articles

NavigateView projects

Interactive work

NavigateView publications

Research

NavigateOpen contact information

Email and public profiles

HelpShow keyboard shortcuts

Available keys

Modelling the eye I: The cornea

Modelling the eye I: The cornea

We start at the very front of the eye. What shape is the cornea, why isn't it a simple sphere, and how do we build it in WebGL?

Ask a graphics programmer to model an eyeball and the first instinct is usually a glass sphere. It renders fast and looks clean. The problem is that a spherical cornea would add spherical aberration, spreading the image of a night-time streetlight.

The clear dome at the front of the eye, the cornea, is a more interesting shape than a sphere, and it does most of the focusing. Of the eye’s roughly 60 diopters of optical power, the cornea supplies about 43. The crystalline lens adds adjustable focusing power; the powers of these separated optical components do not simply add. But how do we know it is not just a solid dome of biological glass? When Antonie van Leeuwenhoek first looked at corneal tissue through his homemade microscopes in the 1680s, he found it was not glass at all, but a tightly woven fabric of living fibers.

In this series we build the eye one part at a time in WebGL. Each section below has a live 3D view, and a Code tab with the full source. Let us start at the front.

The spherical cap: a first approximation

Before hospital scanners existed, people measured the eye with clever tricks. In 1619 Christoph Scheiner described estimating corneal curvature by comparing its reflections with those from glass spheres of known curvature. This was an early comparison method, rather than modern quantitative keratometry. Today, a useful typical value is: the front of the cornea has a radius of curvature of about R≈7.8 mmR \approx 7.8\ \text{mm}.

The visible cornea is a slightly oval window, roughly 11.7 mm11.7\ \text{mm} wide and 10.6 mm10.6\ \text{mm} tall, because the white of the eye overlaps it top and bottom. For a first WebGL model we ignore that and slice a clean cap off a sphere.

For this first cap, 1 scene unit represents 7.8 mm: we normalise its radius to 1. The later conic demos use 1 unit = 1 mm, so their radii can be entered directly. Scaling geometry does not change its shape, but camera distances must use the same units.

In Three.js a sphere already knows how to draw itself. We just tell it to keep only the front cap by limiting the vertical sweep angle:

// A cornea, roughly, is a cap sliced off the front of a sphere.
// The last two arguments keep only the top slice instead of the whole ball.
const geometry = new THREE.SphereGeometry(
  1,               // radius
  64, 64,          // horizontal and vertical smoothness
  0, Math.PI * 2,  // sweep the full circle around
  0, Math.PI / 4   // but only 45 degrees down from the top: the cap
);

So why is a sphere a bad lens? Light rays hitting the steep edge of a sphere bend more sharply than rays near the center, so they focus at slightly different points. The result is spherical aberration: a bright point of light spreads into a soft halo instead of a crisp dot. The naturally prolate, aspheric cornea reduces this aberration relative to a spherical surface.

The aspheric cornea: flattening the edges (the Q value)

The cornea typically flattens toward its edges while keeping the center steeper, reducing spherical aberration. Optical engineers describe this shape mathematically using conic sections (like ellipses or parabolas), governed by a single number: the conic constant QQ. The height of the surface (called the sag, zz) at a distance rr from the center is defined as:

z(r)=c r21+1−(1+Q) c2r2z(r) = \frac{c\, r^2}{1 + \sqrt{1 - (1+Q)\, c^2 r^2}}

Here c=1/Rc = 1/R is the curvature at the very center. The value of QQ changes the shape:

  • Q=0Q = 0 (sphere): constant curvature everywhere. Adds positive spherical aberration in this refracting-surface model.
  • Q<0Q < 0 (prolate): steeper center, flatter edges. A commonly used typical anterior-corneal value is Q≈−0.26Q \approx -0.26.
  • Q>0Q > 0 (oblate): flatter center, steeper edges. Can occur after myopic laser surgery and increase positive spherical aberration; postoperative Q and visual symptoms vary.

A value near Q=−0.53Q = -0.53 can remove spherical aberration for an idealised single refracting surface with a corneal refractive index near 1.376. It is not a universal optimum for the whole eye: it depends on the optical model. In many young eyes, positive corneal spherical aberration is partly compensated by negative aberration from the internal optics, especially the crystalline lens. That balance varies with age and accommodation (Artal et al., 2001).

Translating the sag formula into code is almost a direct copy:

const c = 1 / R;                 // curvature at the apex
const validR = Q > -1 ? Math.min(maxR, 0.999 * R / Math.sqrt(1 + Q)) : maxR;
for (let r = 0; r <= validR; r += step) {
  const root = 1 - (1 + Q) * c * c * r * r;
  const z = (c * r * r) / (1 + Math.sqrt(root)); // surface height at radius r
  // ...place a ring of vertices at this height
}

Use the dropdown below to switch between a typical human cornea, a spherical cornea, and an oblate / post-myopic-LASIK example. The color runs from green at the center to the shape’s color at the rim, to help you compare their shapes; these colors do not calculate refraction.

Asphericity (Q)
Conic constant Q-0.26
Prolate: steep center, flatter edges. Reduces spherical aberration relative to a sphere.
sphere reference
Literature-derived

Q is dimensionless. The −0.26 starting example represents a prolate cornea; individual corneas vary. Slider settings and presets illustrate shape rather than diagnose it.

Corneal shape references

Astigmatism: a cornea shaped like a rugby ball

A spherical cornea is equally curved in every direction, like a slice of a basketball. An astigmatic cornea is curved more in one direction than another, like the back of a spoon or a rugby ball. This is regular astigmatism. Thomas Young investigated astigmatism in his own eyes in 1801, although he attributed his to the crystalline lens.

We model it by giving the two axes their own curvatures instead of sharing one. We approximate this with a biconic surface, a toric-like model with two principal curvatures. In code it is the same sag formula as before, but with a separate curvature for xx and for yy:

// One curvature is no longer enough: cx along X, cy along Y.
// Choose an aperture within both meridians' conic domains first.
const root = 1 - (1 + Q) * (cx*cx*x*x + cy*cy*y*y);
const z = (cx*x*x + cy*y*y) / (1 + Math.sqrt(root));

The two directions of maximum and minimum curvature are called the meridians. In the view below the flat meridian is drawn in blue and the steep one in red. Because the two meridians focus at different distances, uncorrected regular astigmatism prevents a single sharp point focus. Light collapses into two short focal lines with a zone of “least blur” between them, a shape optics calls Sturm’s conoid.

Toric Cornea
X axis: flat meridian (Rx = 7.8 mm)
Y axis: steep meridian (Ry = 6.0 mm)
Z axis: surface height
CurvatureSteep
Flat

Inside the cornea: layers of tissue

The cornea is usually described as five layers. Here we also distinguish the proposed pre-Descemet (Dua’s) layer from the posterior stroma, a classification still debated. They fit into about half a millimeter (typical central thickness is approximately 500500–550 μm550\ \mu\text{m}, with variation between eyes and measurement methods). The thicknesses below are illustrative model values totaling 540 μm540\ \mu\text{m}:

LayerThicknessRole
1. Epithelium≈50 μm\approx 50\ \mu\text{m}Renewing outer cells; gives tears a smooth surface.
2. Bowman’s layer≈10 μm\approx 10\ \mu\text{m}Acellular collagen layer beneath the epithelium; does not regenerate like the epithelium.
3. Stroma≈452 μm\approx 452\ \mu\text{m}Most of the thickness; hundreds of interwoven collagen lamellae.
4. Dua’s layer≈15 μm\approx 15\ \mu\text{m}Thin but very strong pre-Descemet layer.
5. Descemet’s membrane≈8 μm\approx 8\ \mu\text{m}Elastic base that the endothelium sits on.
6. Endothelium≈5 μm\approx 5\ \mu\text{m}Single sheet of cells that pump water out.

Why is it clear? The stroma is made of collagen, the same protein as a white, opaque tendon. The trick is organisation: narrow collagen fibrils have relatively uniform sizes and ordered spacing, so much of their scattered light interferes destructively away from the forward direction (Benedek, 1971; Meek & Knupp, 2015). There is no single half-wavelength spacing cutoff. If the endothelial pumps fail and the stroma swells, this organisation is disrupted and scattering can make the cornea cloudy.

A recent anatomical debate. For over a century, textbooks firmly listed five layers. Then, in 2013, researchers proposed a controversial sixth layer (Dua’s layer), a thin and unusually tough sheet just in front of Descemet’s membrane. While many anatomists still debate whether it is truly a novel layer or just the dense posterior edge of the stroma, its discovery helped explain why a surgical technique that injects an air bubble to separate corneal tissue splits it exactly where it does.

The model below is a schematic cross-section with approximately proportional layer thicknesses, so you can see just how much of the cornea is stroma. The stroma’s interwoven lamellae are simplified to alternating fiber directions (think plywood), and the mostly hexagonal endothelial mosaic is enlarged for visibility. The exploded view separates and rescales the layers. Press the button to pull the layers apart.

Corneal layers (model)
1. Epithelium
50 µm
2. Bowman's Layer
10 µm
3. Stroma
452 µm
4. Pre-Descemet (proposed)
15 µm
5. Descemet's Membrane
8 µm
6. Endothelium
5 µm

The tear film and its oil-slick colors

The very first thing light meets is not cells but tears. A film only 33 to 5 μm5\ \mu\text{m} thick coats the cornea, and its outermost skin is a lipid layer only tens of nanometers thick, supplied by glands in the eyelids. It helps the film spread and remain stable; its contribution to limiting evaporation is more complex than a simple oil barrier (TFOS DEWS II). For this visualisation, we use 4040–100 nm100\ \text{nm}.

Its reflected rays have an optical path difference comparable to visible wavelengths, making thin-film interference relevant—the same effect that paints rainbows on soap bubbles and puddles. Being thinner than one wavelength is not a strict condition for interference. Light reflecting off the top of the film and light reflecting off the bottom travel slightly different distances, so some colors reinforce and others cancel. For this idealised air–lipid–aqueous film, with one phase reversal on reflection, constructive interference satisfies:

2 n dcos⁡θ=(m−12)λ,m=1,2,3,…2\, n\, d \cos\theta = \left(m - \tfrac{1}{2}\right)\lambda, \quad m = 1, 2, 3, \dots

where nn is the oil’s refractive index, dd its thickness, θ\theta the angle of the light inside the film, λ\lambda the wavelength, and mm is the integer order of interference. The RGB shader samples three representative wavelengths and adds a stylised sheen: it is a simplified interference visualisation, not a full spectral thin-film calculation. Drag the model to catch it shifting across the surface.

Tear Film: Thin Film Interference
A wafer-thin oil layer floating on the watery tears. As its thickness drifts, different colors cancel and reinforce, giving the faint oil-slick sheen.

When it goes wrong: keratoconus

If the collagen in the stroma weakens, normal eye pressure can push the cornea outward into a cone. This is keratoconus, and the bulge usually forms low and slightly off-center rather than at the apex.

Biomechanically, keratoconus involves a dangerous thinning of the tissue. But to approximate it purely visually in our shader, we model only the outer shape: start from a spherical cap and add a small Gaussian bump below the center.

let z = Math.sqrt(R*R - rho*rho) - R;   // spherical starting surface
const dist = Math.hypot(x, y + 1.5);    // cone centered 1.5 mm below apex
z += 1.5 * Math.exp(-(dist * dist) / 2); // add a forward bulge

The effect on vision is worse than plain short-sightedness. The cone is not symmetric, so it does not just shift the focus, it distorts it. A single streetlight smears into a comet-like streak (opticians call this coma), and the irregular optics become harder to correct as the condition advances. Glasses can still provide useful correction in mild or early keratoconus. Rigid or scleral lenses can improve irregular optics, cross-linking can stabilise progression, and surgery may be considered depending on severity. Drag the model to see the cone in profile.

Keratoconus
A thinned cornea bulging forward into a cone, low and off-center. Drag to rotate and see the profile.
↓ Inferior (cone forms here)

Measuring the shape: Placido rings

How does an optician measure these tiny bumps without touching the eye? By watching reflections. In 1880 António Plácido used a target of concentric black and white rings and observed its corneal reflection. On a smooth cornea the rings reflect back as clean circles. Where the cornea is steeper, the reflected rings bunch closer together; where it is flatter, they spread apart. A distorted cornea gives distorted rings, like looking through warped glass. Placido-based topographers still analyse reflected rings. Modern corneal imaging also uses Scheimpflug imaging, OCT and other techniques.

For this visualisation, the rings are a curvature-based approximation, not a full geometrical reflection simulation. The blue-to-red colors are the demo’s encoding of flatter-to-steeper regions, not a universal physical color scale.

Topography
Steeper = redder
The rings approximate curvature changes. Red marks steeper regions in this demo’s color key; no reflected rays are traced.
Placido approximation

Putting it together

The final model brings together a biconic front surface, the aspheric QQ flattening, and an offset rear surface to illustrate thickness. The two radii are also expressed as keratometric power, K=337.5/RK = 337.5 / R diopters for RR in mm. This uses the conventional keratometric index of 1.3375 to approximate total corneal power from anterior curvature; it is not the refractive index of corneal tissue.

At extreme slider combinations, the displayed aperture narrows to stay within the conic’s valid domain. The rays use schematic focal distances to show how astigmatism and asphericity spread a focus. The final blur is illustrative, not a quantitative prediction of retinal image quality or visual acuity.

Illustrative blur

D: keratometric power (index 1.3375).

Literature-derived

The 7.8 mm starting radius is a typical schematic anterior cornea. Adjusted radii are illustrative; displayed keratometric power uses the conventional index 1.3375, not a full two-surface calculation.

Atchison & Smith, Optics of the Human Eye (2000), Ch. 2
Literature-derived

Q is dimensionless. The −0.26 starting example represents a prolate cornea; individual corneas vary. Slider settings and presets illustrate shape rather than diagnose it.

Corneal shape references
Literature-derived

The starting central thickness is 550 µm (0.55 mm), a typical example rather than a patient measurement. The slider varies this model dimension.

Corneal anatomy references

A hyperrealistic finish

The models above are built to explain, so they favor clear colors and diagrams over looking real. To close the loop, here is just the cornea dressed for realism: the same aspheric shape, now a clear meniscus dome (an aspheric front surface with a steeper back surface) made of a glassy transmission material with a clearcoat, refracting a synthetic studio environment. The bright highlight riding on the surface is the corneal reflection an optician calls Purkinje image P1, the same reflection Placido rings rely on. Drag to move it around the dome.

Hyperrealistic Cornea
Illustrative

Three.js physical material with an 80–420 nm iridescence range. This is an artistic interference effect, not physiological lipid thickness or a spectral tear-film calculation.

Built to average anatomy: Rant 7.8 mm, Rpost 6.5 mm, Q −0.26, thickness 0.55 mm. Glassy transmission with dispersion, a drifting tear-film sheen, and reflections. Drag to orbit.

That gives us a solid front surface for the eye.

Continue with Part 2: The pupil, where we give the eye an adjustable aperture.

References

  1. Young, T. (1801). On the Mechanism of the Eye. Philosophical Transactions of the Royal Society of London, 91, 23-88.
  2. Helmholtz, H. von (1854). Ueber die Accommodation des Auges. Graefes Archiv für Ophthalmologie, 1(2), 1-74.
  3. Atchison, D. A., & Smith, G. (2000). Optics of the Human Eye. Butterworth-Heinemann, Oxford, Chapter 2.
  4. Maurice, D. M. (1957). The structure and transparency of the cornea. Journal of Physiology, 136(2), 263-286.
  5. Benedek, G. B. (1971). Theory of transparency of the eye. Applied Optics, 10(3), 459-473.
  6. Dua, H. S., Faraj, L. A., Said, D. G., Gray, T., & Lowe, J. (2013). Human Corneal Anatomy Redefined: A Novel Layer (Dua’s Layer). Ophthalmology, 120(9), 1778-1785.
  7. Plácido, A. (1880). Novo instrumento para analyse da curvatura da cornea. Periodico Ophthalmologico, 2(5), 44-49, Lisbon.
  8. Godefrooij et al. (2018). Von Helmholtz’s ophthalmometer: historical review and experience with one of the last surviving original devices.
  9. Artal et al. (2001). Compensation of corneal aberrations by the internal optics in the human eye.
  10. Calossi, A. (2007). Corneal asphericity and spherical aberration.
  11. Meek & Knupp (2015). Corneal structure and transparency.
  12. Willcox et al. (2017). TFOS DEWS II Tear Film Report.
  13. American Academy of Ophthalmology. Keratoconus (EyeWiki); Advanced Corneal Imaging in Keratoconus (2023).