Around this time last year I was playing around with a physics-based ray-tracer for spherically curved space. In spherical space the ray geodesics eventually wrap around, meeting at the opposite pole to the observer. To compound the sphericity I used a projection that wraps the whole sphere-of-view from a point into a long strip.

It's been so long I've forgotten the details of how it works, but I embedded the 3D spherical space in 4D Euclidean (flat) space. I represented ray directions by points on the "equator" around the ray source, and a lot of trigonometry was involved to transform these ray directions appropriately when tracing the rays through curved space. Eventually I optimized the code to use simpler functions like sqrt and arithmetic instead of costly sin and cos calls.

The materials are all physically based, with refractive index varying with simulated light wavelength, which gives a rainbow effect when different colours are refracted by different angles. To get the final image requires tracing a monochrome image at many different wavelengths, which are then combined into the XYZ colour space using tristimulus response curves. I collected some Wikipedia articles together into a little A5 booklet: colour.pdf (and a version with the pages rearranged for printing using bookletimposer: colour-booklet.pdf).

Here are some miscellaneous links related to how Prismatic works:

- Projection
- transformation projection (section cubic to/from spherical map)
- Lambert equal-area projection
- spherical coordinates
- Ray-surface intersection distance
- solve a = b cos x + c sin x
- double angle formulae
- Reflection and refraction
- Lambertian reflectance
- Fresnel equations
- Snell's law
- reflect()
- refract()
- Kramers-Kronig relations
- Absorption and emission
- Beer-Lambert law
- complex refractive index
- absorption spectroscopy
- emission spectrum
- Colour, wavelength, CIE XYZ, sRGB
- colour matching functions (section database / CMFs)
- sRGB specification
- illuminant D65
- CMYK colour model
- Materials
- refractiveindex.info
- corundum
- sapphire
- ruby and sapphire
- ruby
- chemistry webbook
- chemistry webbook UV/visibile wavelengths
- crown glass
- flint glass

The prismatic code itself is online at code.mathr.co.uk/prismatic.