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

calculating RGB from intensity

Started by daniel_i_l Aug 10, 2010 at 5:24 AM 4 replies 2.6k views
Original Post
daniel_i_l
daniel_i_l
I writing a basic ray-tracer and have a question about calculating the RGB values for each pixel. To calculate the color of each pixel we send a ray from the camera to the pixel, use the scene to find all the light sources that contribute to the color of the ray, and add up all the contributions. Like the physical world, there's no limit to the intensity of the ray so we can add as many sources as we want.
Now my question is, what's the correct way to get the RGB color (with a range of 0-255) from the sum I mentioned above? Because it's possible that the sum of all the colors will give RGB values greater than 255. I could simply clamp the values so they fit but that would remove some detail. Would it be better to find the highest value and then linearly scale so that this highest value goes to 255?

Thanks
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Brother Bob
Brother Bob
The rendering you're doing is with a larger dynamic range that what can be presented, so you're basically doing high dynamic range imaging. The process of mapping high dynamic range to low dynamic range for presentation on a monitor, for example, is called tone mapping, and is a huge field of research by itself. Any way to do this mapping is correct in it's own way.

There are plenty of tone mapping operators you can look at, from the very basic clamping or scaling you mentioned, to very complicated ones. Your favorite search engine will help you find information about tone mapping. I would also recommend you look into high dynamic range imaging in general.
TyrianFin
TyrianFin
If you look at light bulb in real world, it looks white(RGB=1.0,1.0,1.0), and if you look at sun it also looks white(RGB=1.0,1.0,1.0). But you also know that illumination power of sun is MUCH bigger than light bulbs.

So conclusion: In real world there is no upperlimit in illumination power!

So if you try to simulate real world lighting in ray-tracer,
you must not limit your maximum light power!

/Tyrian

Ps. like Brother Bob writes take a look at bright side of life.... (HDRI + tone mapping)
daniel_i_l
daniel_i_l
Ok,I'll look up tone mapping. Thanks for the help.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
stalef
stalef
Here is a link to get you started:
http://filmicgames.com/archives/75
allingm
allingm
Just a couple more links if you need them:

http://wiki.gamedev.net/index.php/D3DBook:High-Dynamic_Range_Rendering
http://mynameismjp.wordpress.com/2010/04/30/a-closer-look-at-tone-mapping/

Topic Locked

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

Sign in to reply to this topic.