Automatic Light System for POV-Ray, Version 4d
- Jaime Vives Piqueres: Wrote the first simplistic macros, test & demo scenes, compilation of spectral databases, package preparation & distribution.
- Ive: Teaching Jaime some color science, writing the color space macros, demo and test scenes, compilation of spectral databases.
- Philippe Debar: Donated and helped integrating Skylight.inc, betatesting.
Back in 2002, I started to write an include file to automate the task of creating a light source, specifically the aspects about color, intensity and fading. I was tired of always having to find by trial and error the right combination of these factors for each light_source.
I had in mind a set of macros wich will allow to automatically calculate the color, intensity and fading based on a few fixed rules, as light must behave always the same on real world situations. I started then learning about light on the Internet, searching with google and surfing link after link. After some time, I ended up with some basic principles to apply as rules for POV-Ray light sources creation:
Fading follows inverse square law
First of all, light follows the famous inverse square law. So, fade_power must be set to 2. The fade_distance is set to have an arbitrary and fixed value, because the intensity implementation already uses lumen values with an implicit area. However, there is a global variable to fake an exposure control wich affects the light fading parameters.
High range intensity and proportional brightness
Light intensity must be very high, to achieve a high range of lighting levels across the scene (this is also the reason for the very small value for fade_distance). The actual intensity is not that important, but to have realistic proportions between the different light sources.
So, I decided to simply use the "real" lumen value of the real light as a sort of intensity multiplier, using a global variable to allow increasing or decreasing "brightness" equally for all lights on the scene.
Realistic light colors for the light sources
In real world, (light) color is the perception of a spectrum, and as any perceptual matter, it is very subjective. However, scientists of course developed numerical systems to represent the color of a spectrum, being the CIE XYZ Tristimulus model the scientific standard.
Starting it as a replacement for my former spectral macros, Ive created an amazing set of macros to manage CIE XYZ color space with the SDL, which I inmediately adopted as Lightsys default. This gives Lightsys an accurate and very proportional way to calculate the rgb colors for light spectrums, based on the human eye perception. Ive done all the CIE XYZ color space implementation by himself, and I’ve only acted as betatester and later adapted Lightsys to use it (this also helped me a lot to start understanding this color mess).
Additionally, I provide also a global variable to act as a typical "color correction filter". Although this is more a "photography thing", I have implemented it for completeness.
There are some images to illustrate the purpose and behavior of the system, all created with the test and demo scenes included on the zip.
This is a shot from the scene demo_indoor1.pov. The whole scene uses materials with pigments converted from reflectance spectrums, and lights with colors obtained from emissive spectrums. The light sources were obtained with the help of the Lightsys macros, and it was rendered using CIE sRGB color space and a white point of 5000K.
There is another indoor demo, which illustrates the header of this page.
Thanks to the contribution by Phillipe Debar, Lightsys includes now a version of his Skylight.inc, adapted by Ive as CIE_Skylight.inc. It can be used with the CIE macros to setup outdoor scenes very quickly.
The scene demo_outdoor.pov uses again materials pigments converted from reflectance spectrums, and the light uses the SunColor returned by CIE_Skylight.
This image uses CIE sRGB color space and a white point of 5500K.
Yeah, even for space scenes! The "line spectra" macros and databases can be useful to simulate the colors of elements on nebulae, and the Blackbody() macro is pretty handy to create realistic colors for known star types.
There is another demo scene using the same starfield, but with a moon textured with lunar samples and lighted by an extraterrestrial sun spectrum.
This image uses the CIE-RGB color space and a white point of 6500K.
Assorted test scenes:
There are some more demo scenes on the package, showing other posible uses for the Lightsys and CIE macros, as well for the auxiliar tools and spectral databases.
Here are a some images from the test scenes, to show a bit the internals of the system and how it works.
Cornell box test scene:
This one is the classic Cornell Box test, using the geometry from the scene "cornell.pov", by Kari Kivisalo (included with POV-Ray 3.5). I used the spectrums for light and materials from the original Cornell Box data, and the system settings were tweaked assuming a sRGB camera balanced for daylight, which produced the closest results.
The zip archive contains both my Lightsys includes and the CIE XYZ Color Space includes by Ive, as well as the spectral databases, and the demo and test scenes:
03/22/15 : Updated to version 4d
- corrected some pass-by-reference issue on CIE.inc
- corrected erroneous data on rspd_aster.inc which triggered a bug on the latest POV-Ray 3.7 development branch.
- added some more ASTER spectrums
Unzip it somewhere and it will create a "LightsysIV" folder containing all the files. After reading the help files, you may want to copy all the ".inc" files to one of your POV-Ray library paths, or add one more path for the "LightsysIV" folder to your POVRAY.INI or .povrayrc (recommended).
Additional material (reflective) spectrums sampled by Christoph Hormann:
Additional light (emissive) spectrums collected by users of SU2POV, a POV-Ray exporter for SketchUp. These were sent to me by SU2POV user Clipi, and I just translated them to the spline format used by Lightsys 4. It contains several ANSI luminaries and some real lamps from MAZDA:
Additional wide-gamut color spaces, with values taken from Bruce Lindbloom web site. Added after an interesting email exchange with Daniel Richard G., who made me aware that these color spaces existed. The zip includes an include file with two new color space systems, and a little demo scene to visualize the color space:
For more than a year, I’ve been "researching" a lot on the web, collecting a huge amount of bookmarks more or less related to light, color, photography and other topics. From all that mess I’ve extracted a few introductory links, as a starting point for the curious. Look at the readme files and even the code comments for more links to concrete resources.
Light Measurement Handbook
Gernot Hoffman: CIE Color Space