in Science

The Nature of Light

This is the first part of the tutorial on iridescence. This new series will explore the very nature of light, in order to understand and to replicate how material exhibits colourful reflections. The tutorial is oriented to Unity game developers, although the techniques described can be easily implemented in other languages, including Unreal and

You can find the complete series here:


Iridescence is an optical phenomenon which causes objects to change colour as the angle of illumination or the angle of view changes. It is because of this effect that bubbles appear to display such a variety of colours.

A bubble, by Brocken Inaglory

Iridescence can also occur on spilt oil, CD-ROMs, and even on fresh meat. Many insects and animals use iridescence to create colours, without the need for actual pigments.

This is because iridescence occurs from the interaction between light and the microscopic structures that all those things have on their surfaces. Both the tracks of a CD-ROM and the scales of an insect’s exoskeleton (images below by Nikola Rahmé) are on the same order of magnitude of the wavelengths of light they interact with.  Iridescence, in fact, is possibly the first phenomenon to be discovered that really betrayed light’s real nature as a wave. We cannot either explain or reproduce iridescence without first understanding what light really is, how it works and how is perceived by the human eye.

The Nature of Light

Like most subatomic particles, light simultaneously exhibits behaviours that are commonly associated with particles and waves. It is not uncommon to see light modelled as either one of those. For most applications, light can be seen as made of trillions of individual particles, called photons. Most shaders, for instance, assume photons behave like tiny billiard balls, bouncing on objects with the same angle they hit them (diagram below).

But light can also be modelled as a wave. While physicists will be familiar with this concept, developers might not. So let’s spend some time trying to understand what it means for light to be a wave.

We’re all familiar with ocean waves. Each point on the surface of the ocean has a height. The higher it is from its average value, the larger a wave is. Once the surface of the water is disturbed, waves keep propagating through the ocean until their energy is dissipated.

Light is a wave, but instead of being measured as the height of a water surface, it is then defined as the energy that the electromagnetic field possesses at any given point. Under this model, light is a disturbance in the electromagnetic field, which propagates through space. We can imagine a light bulb either causing a wave, or emitting many photons all around itself.

The amount of energy a photon carries determines the colour of the light. Photons with lower energy are perceived as red; photons with higher energy are perceived as violet. Waves have a property that is analogous to the energy their particle counterpart possess: a wavelength. Intuitively, that is the distance between two peaks in the wave.

Light always travels at the same speed (approximately 299,792,458 metres per second), meaning that electromagnetic waves all propagate at the same speed. While their speed is fixed, their wavelengths vary. Photons with higher energy are waves with a shorter wavelength. It is the wavelength of a light wave that ultimately determines its colour.

As it can be seen in the diagram above, the human eye can perceive photons with an associated wavelength ranging from approximately 700 nanometers to 400 nanometers. A nanometre is a billionth of a meter.

❓ How small is a nanometer?
When approaching the smallest scale at which Nature works, it can be hard to get a grasp of the sizes we are discussing. The average human person is approximately 1.6 metres tall. The width of a human hair is around 50 micrometres (50 μm). A micrometre is a millionth of a meter (1 μm = 0.000001 metres = 10^{-6} metres). A nanometer is a thousandth of a micrometre (1 nm = 0.000000001 metres = 10^{-9} metres). So, the wavelength of visible light is approximately one-hundredth the width of a human hair.
What’s next?

After this brief introduction, the rest of this tutorial will focus on understanding and implement iridescence in Unity.

  • Improving the Rainbow. As we have said before, different wavelengths of light are perceived as different colours by the human eye. The next two posts will focus on how to associate those wavelengths to RGB colours. That step is essential to replicate iridescent reflections with a high degree of accuracy. Those posts also introduce a novel approach that is both physically accurate and computationally efficient.
  • Diffraction Grating. Part 4 and 5 of this series will focus on diffraction grating. That is the technical name of one of the effects that cause materials to exhibit iridescent reflections. Despite being very technical, the derived equation that governs this optical phenomenon is very simple. Feel free to skip Part 5 if you are not interested in the Mathematics behind diffraction grating.
  • CD-ROM Shader. The core of this series is the actual CD-ROM Shader. It uses the knowledge gathered in the previous posts to finally implement diffraction grating in Unity. It extends the Standard Surface shader of Unity 5; making this effect both physically based and photorealistic. With very little effort you can change it to fit other types of iridescent reflections based on diffraction grating. An additional post will show how this technique can be implemented on mobile devices in a very efficient way.
  • Thin-Film Interference. Diffraction grating is not the only way in which iridescence can occur. Thin-Film Interference is another physical phenomenon that can split white light into its components, causing iridescent reflections to appear. This is what gives bubble and spilt oil stains their typical appearance. Once again, we will investigate the Mathematical foundations of this optical phenomenon to derive physically based equations for our shaders.

I hope you will stay with me through this journey into one of the most beautiful phenomena that materials exhibit.


This post introduced the new series on iridescence. The rest of this series will explore how to simulate and implement iridescent reflections on a variety of materials. From bubble to CD-ROMs, from spilt oil to insects.

You can find the complete series here:

Become a Patron!
You can download the Unity package for the CD-ROM Shader effect on Patreon.

💖 Support this blog

This website exists thanks to the contribution of patrons on Patreon. If you think these posts have either helped or inspired you, please consider supporting this blog.

Patreon Patreon_button

📧 Stay updated

You will be notified when a new tutorial is released!

📝 Licensing

You are free to use, adapt and build upon this tutorial for your own projects (even commercially) as long as you credit me.

You are not allowed to redistribute the content of this tutorial on other platforms, especially the parts that are only available on Patreon.

If the knowledge you have gained had a significant impact on your project, a mention in the credit would be very appreciated. ❤️🧔🏻

Write a Comment



  • CD-ROM Shader: Diffraction Grating - Part 2 - Alan Zucconi August 4, 2020

    […] Part 1. The Nature of Light […]

  • CD-ROM Shader: Diffraction Grating - Part 1 - Alan Zucconi August 4, 2020

    […] Part 1. The Nature of Light […]

  • The Mathematics of Diffraction Grating - Alan Zucconi August 4, 2020

    […] Part 1. The Nature of Light […]

  • Understanding Diffraction Grating - Alan Zucconi August 4, 2020

    […] first post in this series, The Nature of Light, introduced the dual nature of light, exhibiting behaviours which are typical of both waves and […]

  • Improving the Rainbow - Part 2 - Alan Zucconi August 4, 2020

    […] Part 1. The Nature of Light […]

  • Improving the Rainbow - Part 1 - Alan Zucconi August 4, 2020

    […] Part 1. The Nature of Light […]