Kelvin to RGB Lamp Color Converter

Here’s the initial version of my python Kelvin to RGB converter:

For people unfamiliar with the “temperature” measurements for lighting, incandescent sources can by represented in Kelvins. For example, a candle might be 1800K, and lightbulb around 3000K, noon-day sun would be about 5000K and partly cloudy sky is about 8000K or more.

Films have a white-balance that’s usually 3200K for indoors and 5500K for outdoors. The difference between the light source temp and the reference determines the visible color cast of the light. Temps less than the reference get more orange and temps greater get more blue.

For example, a lightbulb appears creamy white and light from a window is blue when using indoor film or with a camera white-balanced that way. Using outdoor film, however, the bulb’s light will cast yellow-orange and sunlight will appear white.

This script allows you to manually set a reference and light temperature or choose from a set of approximate preset values. You can select any of the lamps that exist in your blend at the time the script is started. The GUI will compare your current light color with a preview color, and allow you to change the color of that light from its interface.

It’s can be useful for:

  • rapidly producing realistic lighting scenarios
  • compositing blender-created objects on to actual photos or films
  • learning more about lighting and color
  • just messin’ around

Let me know what you folks think! If the response is good, I’ll get in touch with the bundled scripts group and see if this is something worth including in the distributions. Other 3D packages have something like this, so it makes sense that we would, too!

Thanks for adding the presets. I’ll try this out. I think this is going to be a very useful script as a starting point for lights. Then with the ability to change things you can add your own artistic interpretation.

Wouldn’t this be useful as a slider in the lamp buttons (Coded into blender instead of a script)?

I’ve been thinking about that. It would be pretty cool. There are a couple of things to consider, though. First, there needs to be at least two sliders: one for the reference temp and one for the light temp. Also, having the preset pulldown menus is extremely valuable, so finding a place for them is important, too, not to mention having a fairly simple way to ad more presets to the list.

All this could be done, but I haven’t quite figured out how to do it in the limited real-estate provided by the color changer in the Materials buttons. Plus, it’s a heckuva lot easier building the GUI in a script, at least until we’re satisfied with the layout and functionality :wink:

All that being said, take a peek at the script and let me know if there’s a good way we can start thinking about making a change within the app itself, since that’s really a good goal to have. I’ll have to tune up my C++ skills, but it’s probably worth it.

The reference slider could be in the World buttons, since it’s usually going to be a value global to a scene.