Skip to main content
GameDev.net gamedev.net
🔒 Locked

Light temperature, color balance, and film selection

Started by bishop_pass Jan 26, 2003 at 7:00 PM 33 replies 10.6k views
Original Post
bishop_pass
bishop_pass
You can select your light color based on temperature, balance it with a particualr type of film, such as a tungsten based film, or a daylight based film. Daylight film is typically optimized for 5500 degrees Kelvin. Unlike real cameras though, you have the additional flexibility of balancing each light with a different film. But if you want to achieve the look of film, you can balance all of the lights with the same color temperature. By reducing the color temperature of the film, you make redder light expose more like white light. By increasing the color temperature of the film, you make blue light expose more like white light. Given sources on the Web, I have developed this little piece of code, and it's great fun. I may post some screenshots if I get around to it. [edited by - bishop_pass on January 26, 2003 8:03:17 PM]
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
Samith
Samith
sounds like a good idea, lighting can make a games graphics go from mediocre to really nice in an instant.



Sam Johnston (Samith)
bishop_pass
bishop_pass
Taking it a step further, I'm thinking about being able to specify the contrast between lit objects and those in shadow. Technically, this is just a contrast function, but if we look at it from the light initialization functions, we can adjust the ambient levels of light to simulate what we're after. Hue and saturation are other factors that can be modified.

The idea is to take a rendering pipeline, and create a set of functions which adjust the tonality and contrast to simulate certain types of film and exposure. In effect, the idea is to stylize the rendering, but only in terms of tonality, contrast, and saturation.

Photographers use the same technique to create mood in their photographs, punch up the colors a little, darken the shadows, etc. The tools available traditionally to the photographer are exposure control and film.

The first part which I already mentioned, is the color balance of the film. Secondly, is the contrast of the film.

I made the observation that a lot of the realtime renderings (even the very good ones) we see posted for game graphics seem to suffer from a muddying effect, where the programmers seem to be a little insensitive to tonality and mood, but are more "in awe" of the detail and texture they have created in their realtime imagery. I am a 100% advocate detail and realism with regard to realtime graphcis, but tonality and contrast should play a role as well.

Have you seen a game screenshot depicting noontime light effectively? What are the user's expectations with regard to noontime light? To begin, we would expect heat. Not warmth, as in golden tones, but a white hot heat. But at best, we often get what often looks like an overcast day. Shadows can and will help here, but there are two other factors: the color of the light, and the contrast between shadow and illuminated objects. The contrast should be high, and the light should have a blue tone to it. Objects illuminated by the sun can appear just a smidgeon overexposed, indicating their brightness and heat. Overexposure is a relative term, and I mean, perhaps one third overexposed. This will bring a little detail into the shadows, but have them still remain relatively dark.

Also, our expectations are further conditioned by photography. Outdoor film is usually balanced for 5500 degrees kelvin, and is often very contrasty. This parallels effectively the contraction of the pupil due to the bright light, creating dark shadows. Also, with a color balance of 5500 degrees Kelvin, daylight colors, which approach 6000 degrees overall will be rendered with a slightly bluish cast to them. Outdoor shade, which has a color temperature of about 7500 degrees will be rendered with an even greated bluish cast. The noontime sun has a typical temperature of 5200 degrees, meaning film balanced for 5500 degrees will render it approximately white.

[edited by - bishop_pass on January 27, 2003 5:09:46 AM]
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
Crispy
Crispy
bishop_pass: I find your "ruminations" utterly fascinating. The topic you''re researching is, admittedly, interesting and it would be very exciting to see some screenshots and perhaps some references to "real" material on the subject in the future.

However, I must diasect your discussion further to fully understand what you''re trying to do. For one, creating highly detailed levels in a real time game will not be accepted by most audience you might find - instead most people, myself being one of them, are looking for the speed factor rather than extreme eye candy. I''m sure you have a very good understanding of how bad an effect a realistic lighting model can have on a real time application (especially when it is poorly implemented). You can see this from the gossip about and Carmack''s own hints on what Doom III engine will be like. A realistic lighting model is one part of the game.

I am aware that the problem you''re posing is a somewhat different one, dealing with changes in ambient lighting instead of positional lights, and relating more to the type and properties of the viewport rather than to its position or orientation. Therefore, could you give slightly more insight to your ideas on the technical side (not pertaining to actual physics, but to actual solutions/implementation(s)). Basically the way I see it, the problem you''re describing can be solved by drawing simple quads over the viewport thus changing the ambience of the game (?). The topic in itself, however provides a lot more possibilities as far as I can see. True, I have never tried to implement a complex lighting model myself, but I will try to get round to it in near future.

Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
bishop_pass
bishop_pass
Regarding detail, it is pointless to argue against it, because the trend is (and will continue to be) more detail in successive games, with no drop in framerate, for three reasons:

1) Tomorrow's graphics hardware can handle a higher polygon count and fill rate than today's.
2) Tomoorrow's CPUs can actually implement occlusion and LOD algorithms that were computationally expensive today.
3) Tomorrow's graphics hardware actually provide additional mathematical functionality enabling a further set of detail rendering algorithms to be employed.

Any game which is too slow today will be intercepted by faster hardware tomorrow. Any game which is being developed today will not be running on today's distribution of hardware. In fact, any game being released today will not be running on today's distribution of hardware. To insure that a game's graphics become obsolete quicker, a good strategy would be to target its highest capability for the highest level of hardware available today on consumer hardware. A better strategy would be to target its highest graphics capability for hardware that will not quite be available on the day of its release. Doom 3 would be a pointless endeavor if it didn't take advantage of these factors. Nobody would want Doom 3 if it wasn't what it is. Be appreciative that there already exists a game ready for high-end hardware. But please, if this is a discussion worth continuing, start another thread for it.

With all that said, this has nothing to do with what this thread is about. My mention of high detail scenes was too show that today's game graphics programmers are more sensitive to detail and natural phenomena than visual color perception as affected by light temperature and color balance.

Most of the discussion focuses around calculating the color of a light source, which is equivalent to about ten lines of code per light source, and either is done once per game, or once per frame if you wish to interpolate between different film types per frame.

The idea here is to apply color temperature as it applies to real world lights, and then interpret it with a particular type of film.

[edited by - bishop_pass on January 27, 2003 2:22:32 PM]
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
FanThomaS
FanThomaS
Bishop_pass: "Given sources on the Web" But where i searching a lot with google ( like "color temperature", ect... ) but not found anything releated to film - color temperature ( what is the temperature of a film... ). Can you halp me width some url ?

bye, Fanthomas
bishop_pass
bishop_pass
Start here. That''s a good place to get the RGB triple for a particular color temperature.

But that value alone is of no value until you also establish a color balance which is another temperature. For example, our light source may be 6000 degrees Kelvin (this corresponds to sunlight through haze), but the value by itself has little meaning until we add color balance to the mix. If we render our image with standard daylight film, our color balance value will be 5500 degrees Kelvin. This means that a light source of 5500 degrees Kelvin will be rendered as white. A higher temperature light source (our 6000 degree sunlight through haze) will then have a bluish cast to it.

And then we have to work into the whole mix light intensity, and how this exposes in our final rendering. You can be arbitrary if you want, but the idea is to build a model that appears to be consistent and fully conveys the intensity spreads between light and shadow effectively to capture the heat/warmth/brightness in the scene.

Here are some approximate constants for you:

#define K_MATCH_FLAME 1750
#define K_CANDLE_FLAME 1880
#define K_SUN_SUNRISE 2500
#define K_SUN_SUNSET 2500
#define K_TUNGSTEN_BULB 2700
#define K_QUARTZ_LIGHT 3350
#define K_SUN_NOON 5200
#define K_DAYLIGHT 6000
#define K_SUN_CLOUDY_HAZY 6000
#define K_SKY_OVERCAST 6750
#define K_OUTDOOR_SHADE 7500
#define K_SKY_PARTLY_CLOUDY 9000


But remember, that does not alone define the color of your light. As I pointed out, you need to establish the color balance.

Here is some more information. You might notice, as I stated on other threads (the atmospherics one, for one) that high altitude has a deeper blue sky, and a brighter sun, and this results in a a much higher light temperature - in fact up to 20,000 degrees Kelvin.

In general, daylight balanced film has a color balance of 5500 degrees Kelvin. Tungsten based film has a color balance of 3200 degrees Kelvin.

Unfortunately, I have a problem with my Web hosting right now, so I can''t post any images that I have rendered.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
FanThomaS
FanThomaS
Thank you! I''m reading like a mad

"upload it on davepermen.net
just click on free, and upload them there.. up to 2mb per file. and there, its for free, for me, too:D

then link them in here.. "


<- Try this for your screenshots! I''m wait your screenshots!

bye, Fanthomas
bishop_pass
bishop_pass
Ok, I''ll upload them now. Bear in mind that I haven''t gone through a fine tuning stage yet, and my monitor has poor contrast, so what looks like a fair representation on my monitor might be too contrasty on yours. Basically, I''m saying that my example imagery might not be that impressive to you, but I''ll upload now...
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
FanThomaS
FanThomaS
Bishop_pass: Thank you again! I saw your screenshots ( the vases ), perfectly demonstrated what I want. I think this is a very important area of realtime-rendering. Thanks!

bye, Fanthomas
bishop_pass
bishop_pass
Let me know if displaying the images will eat up your bandwidth, if so, I''ll just post links...

Regarding the vase''s texture, forgive me - it''s just a simple planar projected texture. These are quick hack together renderings, nothing spectacular.

Ok, here we have an image shot wtih daylight film (balanced for 5500 degrees Kelvin) simulating a noon time shot. The sunlight has a temperature of about 5200 degrees Kelvin, the shade has a temperature of about 7500 degrees Kelvin. Also, a ''contrasty'' film was simulated, to better acheive the heat and bright intensity of the harsh noon time sun, and this of course leads to darker shadows.





Below, we see a what we might see on a more overcast day. In fact, I balanced the light sources to equal the color balance, resulting in white light, and I turned down the contrast. The image looks reasonable for an overcast day. But do you notice that a lot of game graphics have the muted tonality you see in the image below? Kind of flat, isn''t it? It doesn''t show the bright heat that the above image shows.





Below is late afternoon. We''re still using daylight film, but the color temperature of the sunlight has been reduced to about 3500 degrees Kelvin. The ambient light has a higher color temperature, as it is reflecting the sky.





Here we have illumination at sunset. The sunlight''s color temperature is about 2500 degrees Kelvin.



_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
bishop_pass
bishop_pass
Also, this guy has done some fiddling with color temperature.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
python_regious
python_regious
Wow, those are impressive screenshots. From this you could easily interpolate temperature values and create a decent day cycle yes? Very interesting... Beats hacking with light colours.

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
Samith
Samith
those are some nice pictures there bishop, and those sites are pretty neat too, thanks for all the info



Sam Johnston (Samith)
davepermen
davepermen
cute stuff i can find on my server. really cute stuff. hehe:D

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
bishop_pass
bishop_pass
If you don''t want them hotlinked, I can fix it. Actually, I have likely resolved my host/server issues, so I can ultimately transfer the images over.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
davepermen
davepermen
no, i like it. no problems. i don''t pay that server, and i have one gig to fill..:D bandwith is free..

don''t ask me why.. hehe:D but yes, its all legal that way, it was a gift:D

my gift, as thanks for this gift, is giving the space free for hosting data. thats all. hotlink what ever you want. you can not hurt me.. well you could.. but not by hotlinking..

if the pics would be ugly, it would be an entierly different topic:D

but this topic btw is very interesting.. you changed my view of colors dramatically, gave it a logical physical base, more or less.. or so.. or not.. or what ever.. i''m just tierd. i need holidays to catch up with all those formulas and topics:D

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
bishop_pass
bishop_pass
Thanks.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
bishop_pass
bishop_pass
For those who are curious, here''s how you balance the color given color temperatures:

K = color of light source in degrees Kelvin.
B = color balance of film in degrees Kelvin.

Use K to lookup Kc, which is the color of your light source.
Use B to lookup Bc which is the color of your color balance.

Lc (color of light) = Kc / Bc.

Normalize Lc. You now have the color of your light. You must normalize it for it to have any meaning. Notice two things. If K and B are equal, your color will be white. This is exactly what you want. That is the whole point of color balance. Also, notice that once the colors are normalized, they won''t have the brightness that you want, but they all will have equal brightness. That''s a good thing, because we can then scale that value by our brightness scalar. What this means is that one light with twice the brightness of another simply needs a brightness factor twice that of the other light.

We havn''t yet addressed brightness perception issues, which are a function of one''s monitor, one''s eyes, and contrast. These are things that you can either apply a rigorous study of, or use trial and error to acheive what you want. Be aware of two things though. Bright scenes (such as noon time light) should have high contrast. Dim scenes should have lower contrast. Dim scenes illuminated by bright lights should also have a somewhat high contrast.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
technobot
technobot
Hmm.. that''s a very interesting discussion (esp. now that you''ve written how to implement that ), but all of this is assuming we''re treating our rendering as if we''re filming the scene through a camera. What if we''re treating it as if we''re seeing the scene through a human eye? What adjustments would have to be made in that case?

Michael K.,
Designer and Graphics Programmer of "The Keepers"



We come in peace... surrender or die!
Michael K.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.