PDA

View Full Version : I need help ! light intensity



Morglum
03-05-2002, 09:06 AM
Hi !

I have to write a building illumination simulation : So I've got a building, and I must write an application which lets the user position lights (ie, floodlights...) around it to visualize the result. It's very important for the user to test different light intensities. Here's my problem : I'm not an opengl guru, and I don't know how you specify a light's intensity in opengl : you specify some parameters like colors, but I haven't seen anything about light intensity.
Please, can you help me ? Is there any way to specify a light's intensity ? Or, do you know any way of working around this problem ?

Any help would be highly appreciated !
Morglum

zeckensack
03-05-2002, 09:15 AM
you specify some parameters like colors
Trivia:
What's the difference between the following two colors:
1.0f; 0.5f; 0.0f

0.5f; 0.25f; 0.0f

Answer this riddle and wisdom ye shall receive ...

Morglum
03-05-2002, 10:42 AM
Ok I see what you mean, but the problem with this approach is that you can't get anything brighter than 1.0, 1.0, 1.0. In the real world, there's no upper bound to a light's intensity.

Anyone ?

davepermen
03-05-2002, 11:01 AM
no way in gl directly..
looks like you have to generate the lighting yourself, some "dynamic lightmaps".. or something.. i dunno

if it needs to be placed in realtime, stick with 0 to 1 values..
if they place it in some editor and then watch after the placing (possibly after a second, who knows) a final result, generate lightmaps.. you can generate the maps at start, and then simply draw the lightings onto it when needed.. needs some texture-updates and some processing before you see the lights but like that you get full freedom on what you wanna do..

fritzlang
03-05-2002, 11:06 AM
Yes, tecnically the dynamic range is not
very real-world. But many things contribute to how you percieve intensity. The peak is 1,1,1 but your brain may still percieve an image as much more over-exposed, burned-out, glowing etc. Use register combiners to enhance your output!

Relic
03-05-2002, 11:46 PM
Originally posted by Morglum:
Ok I see what you mean, but the problem with this approach is that you can't get anything brighter than 1.0, 1.0, 1.0. In the real world, there's no upper bound to a light's intensity.

Anyone ?


Note this from the OpenGL specs:
"Lighting Operation
A lighting parameter is of one of five types: color, position, direction, real,
or boolean. A color parameter consists of four floating-point values, one
for each of R, G, B, and A, in that order. There are no restrictions on the
allowable values for these parameters."

That means lights can be brighter than white, though resulting colors on the screen can only be max. RGB (1,1,1).
Interestingly you can even specify negative lighting colors (black hole style of lights) http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Relic (edited 03-06-2002).]

Devulon
03-06-2002, 01:56 AM
I have to agree completely that opengl has really fake light. But to be honest its not an opengl problem its just a problem with computers in general. RGB colorspace is far from the way light interacts with our eyes in the real world. YUV colorspace which is what divx movies and the like use is much closer to the way we percieve light. I really don't feel like explaining what the difference is. Of course there are the other colorspaces such as CYMK and all that jazz. There really are an infinite number of frequecies of light within the visible light spectrum so there theoretically should be an infinite number of different colorspaces. All right enough already. The question was answered a while ago. The color intensity is the light intensity. Its that simple.

You really don't need anything brighter that 1. The reason color is clamped between 0 and 1 is because at 1 saturation occurs (not in the real world) but in a computer it does. Or at least the 1 is interpreted as such. Also its just nice to have things such as colors be 1 clamped floats. They then scale nicely for framebuffer output. Very convenient.

Happy Coding.


[This message has been edited by Devulon (edited 03-06-2002).]

Morglum
03-06-2002, 02:35 AM
Wait a minute, Relic !
Are you saying that all that I have to do, to get a very bright light, is to set its color to 100,100,100 ??? That would be marvellous !

Davepermen, thanks for the idea of lightmaps, but there's one problem : my model is loaded from a 3dsmax file, so it might have a large number of faces, say more that 1000. Should I really build more that 1000 textures ? (If I've well understood, a lightmap is a texture) Is this reasonnable ?

Bob
03-06-2002, 02:47 AM
Yes you can set the light color to RGB = (100, 100, 100) (I assume you mean floats), but the result after the lighting equations will be clamped to [1, 0].

zed
03-06-2002, 08:04 AM
>>Yes you can set the light color to RGB = (100, 100, 100) (I assume you mean floats), but the result after the lighting equations will be clamped to [1, 0].<<

that is no problem because 1.0 is the maximum value ie 1,1,1 is white + u cant have brighter than white on the computer screen

Furrage
03-07-2002, 08:58 AM
I thought the light's intensity was clamped before being used in colour calculations. Are you saying they are clamped after calculations (reflection, etc)?

Relic
03-08-2002, 02:16 AM
Yes, only the resulting color values are clamped to [0,1] after all lighting calculations have been performed.

davepermen
03-08-2002, 07:21 AM
Originally posted by Morglum:
Wait a minute, Relic !
Are you saying that all that I have to do, to get a very bright light, is to set its color to 100,100,100 ??? That would be marvellous !

Davepermen, thanks for the idea of lightmaps, but there's one problem : my model is loaded from a 3dsmax file, so it might have a large number of faces, say more that 1000. Should I really build more that 1000 textures ? (If I've well understood, a lightmap is a texture) Is this reasonnable ?

hm.. you can have one texture over several faces.. like you can have a standart texture over the whole mesh.. why should you need to texture each triangle with an own texture?!?!