Learn Rainbows with Threejs

demo

I recently refreshed my memory on how rainbows work, and that led to this…

Each drop sends light in many directions (like a mini laser pointer) but you only see the rays that happen to reach your eyes. That means you’re always standing at the tip of the cone that forms your own unique rainbow.

The code is a mess but mathematically (i think) mostly right.


4 Likes

Rainbows are fun, they beautifully mix reflection and refraction.

The rainbow ring in the simulation has quite narrow red and violet parts of the spectrum. Is this expected? Do you plan to add the secondary rainbow? Or supernumerary rainbows with some interference?

1 Like

They are great. I too think the red and violet bands look narrow (in the ring)… I think it’s because the shader blends neighboring colors, and red/violet are missing a neighbor. just my guess tho.

A secondary rainbow would be nice. Each drop location is a function of the observer_location, color_refraction_angle. With pen and paper, I could get the xyz of the secondary rainbow drops, but not sure I want to do that yet, lol.

Supernumerary interference would be awesome, but this model only uses refraction angles, no wave math.

1 Like