Original Post
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
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