Raymond is a physics-inspired raytracer for Fragmentarium.
git clone https://code.mathr.co.uk/raymond.git
Features large spheres (1m radius) of different materials (glass, quartz, water, diffuse) on a diffuse checkerboard, lit from above.
(video 5.9MB) (image 1.2MB)
Features pinhole camera vignette, a thin film soap bubble material, and a skybox image-based background texture using a CRT phosphor model.
Reichstagsufer, Berlin-Mitte bei Nacht
by Ansgar Koreng
license CC-BY-SA 3.0 (DE)
Syntopia's blog has a good introduction to the technique Raymond uses to find the nearest intersecting surface along each ray of light (traced backwards from camera into the scene and eventually hitting a light source).
Raymond traces one wavelength of light at a time, allowing realistic lighting effects such as index of refraction varying with wavelength causing rainbow fringes. However, polarization of light and diffraction are not yet supported; and structural colour must be simulated on a per-surface material basis.
Raymond needs to generate pseudo-random numbers in various places (such as choosing whether to follow the reflected or the refracted ray, or which direction to scatter at diffuse surfaces). These are based on a hash of seed values, initially based on pixel coordinates in the final image and other similar data. Raymond lets you choose your own hash, providing some examples from Bob's integer hashes page.
Raymond so far only provides a simple pinhole camera model, with vignette using the formulas on this French page: Modèle du vignettage des appareils classiques. The interior of the camera is perfectly black, so increasing the aperture only has the effect of blurring the image. Other cameras including lenses may be added in the future.
The film converts intensity at a wavelength into a linear RGB triple which can be accumulated and displayed. Two film models are included in Raymond thus far: colour using the CIE XYZ standard colorimetric observer (tristimulus response curves); and black and white using Ilford FP4 Plus camera film data.
The final image is accumulated into a linear RGB buffer, which is converted to sRGB on display.
Images textures are usually in the sRGB colour space, but Raymond needs to know the linear light intensity at each wavelength. To do this, Raymond models the texture as a screen, prebuilt models include CRT (cathode ray tube) and LCD (liquid crystal display). Data for the models are derived from the figures in Marcel Patek's LCD Displays page.
There is also a D65 standard illuminant that can be used for lights.
Provided materials include:
Raymond needs two scene definition functions, one for distance estimate, and the other for distance estimate and surface interactions. The first is typically called 100s of times more often than the second, so don't be tempted to define the first in terms of the second or performance will be poor. It is possible to use preprocessor macros using GLSL overloading to be able to write the scene definition once, and still get two separate optimized implementations. See the examples for details.