PDA

View Full Version : Suggestion please (Bitmap based lighting)


Celarien
09-29-2006, 08:01 PM
Suggestion needed please...
I want to make lights based on the intensity of a set of pixels in a bitmap... What do you think is the best? I thought of getting an average of the RGB values of all selected pixels and applying the intensity based on 0 (no lighting) if black to a max value, say 5, if white...

(I'm talking about light intensity, not color)

HalfVector
09-29-2006, 09:29 PM
You could calculate the light intensity based on the luminance of a given pixel. The formula for calculating luminance is:

luminance = 0.299 * R + 0.587 * G + 0.114 * B

This will gives you a number between 0.0 and 1.0. Then you can multiply the luminance by the base light intensity and you are done.

Hope that helps.

NOTE: R, G and B are the normalized red, green and blue color components, i.e., they range between 0.0 and 1.0.

Celarien
09-29-2006, 09:41 PM
Alright... It was sort of what I was thinking... But not with these exact values, but I'll try that =)

Thanks!

CGTalk Moderation
09-29-2006, 09:41 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.