PDA

View Full Version : light intensity, part 2 : physical intensity



Morglum
03-08-2002, 03:30 AM
Hi !

Suppose that I want my opengl scene to be lighted by a 5000 Watt floodlight. How do I tell this to opengl ?
I mean, how do I convert a physical intensity, expressed in Watts (or any physical unit you like) into parameters to pass to glLightfv ???

Btw, is opengl's lighting model accurate enough for realistic physical-based simulation ?

Thanks in advance !

Morglum

Bob
03-08-2002, 04:42 AM
As always, OpenGL doesn't deal with any kind or units. If you as a programmer consider the color (1, 1, 1) in your specific application as a 1kW light source, then a 5kW light source would have the color value (5, 5, 5).

It's always relative, and it's always you that defines a reference.

"Acurate enough" is also relative. Only you can answer the question if it's acurate enough for YOU.

zeckensack
03-08-2002, 05:27 AM
And please remember that displays (read: monitors, projectors, TFTs ...) won't be capable of blinding anyone, if that's what you're trying to do. http://www.opengl.org/discussion_boards/ubb/confused.gif

Morglum
03-08-2002, 06:31 AM
Originally posted by Bob:
If you as a programmer consider the color (1, 1, 1) in your specific application as a 1kW light source, then a 5kW light source would have the color value (5, 5, 5).


Aah that's part of what I wanted to know : you're saying that opengl intensity is proportionnal to physical intensity. Are you sure of this ? Maybe does this require some gamma correction ?

Further, does anyone have some idea of what the proportionnality constants might be, for each kind of lightsources ?

zeckensack, i've said I wanted to enlight my scene, not the user http://www.opengl.org/discussion_boards/ubb/rolleyes.gif

Siens
03-08-2002, 07:36 AM
1. in my opinion you need lightmaps if you want to show a building in realistic environment. With the lightmap you have shadows with opengl lights you have ... http://www.opengl.org/discussion_boards/ubb/biggrin.gif
if you have 1000 polygons you can use only one high resolution lightmap for the building and one for the floor. Then you have different texels for the polygons. It is not necessary to use different lightmap for every polygon. The lightmap rendering is not too complicated you need only some raytrace knowledge but in this case the light goes from the surface to the lamp texel by texel and from the camera to the render space pixel by pixel.
2. The light intensity and COLOR:
With the lightmap you can give any value for the light because you calculate the final intensity:
intensity=base_int(1/a*dist*dist+b*dist+c)*cos(alf)
base_int can be "5000W"
BUT:
the color can be change in this case!!!

You have: 100,100,200 RGB color for the light.
You want to increase the light intensity then :

100,100,200 -> 110,110,220 -> 120,120,240 -> 130,130,260? it cab be only 255 maximum and here the color can be change.

you will have color circles around the center...

Morglum
03-09-2002, 12:03 AM
Ok but I need realtime rendering. How much time would it take to compute such a lightmap ?

Siens
03-09-2002, 01:13 AM
It depends on:
- CPU
- lightmap size
- number of the faces
- number of the lights
- shadow type
- and your code!

this can be a prerender function. Do you need shadow on a flat surface or you have complex environment? For flat surface you can generate the shadow with simple projection. View from the light position etc. there are some possibility to do this type of shadow.
What do you want to do exactly?

jwatte
03-09-2002, 08:24 AM
You don't need a light map, all you need is a multipass additive lighting algorithm.




Clear to ambient
Foreach light (diffuse):
Draw all geometry illuminated by light,
in light's color with full-bright material
using additive mode (GL_ONE, GL_ONE)
Then modulate the color map onto the light
(GL_ZERO, GL_SRC_COLOR)
Foreach light (specular):
Draw all geometry illuminated by light,
in light's color with full-bright material
using additive mode


The GL frame buffer is in linear space. Gamma correction, if any, happens once the RAMDAC presents the pixels to the monitor. There are a few problems here, though:

8 bits isn't good enough for high-quality imaging in linear space
Many user monitors aren't gamma corrected by default
Thus, many artists/engines/whatever use textures that have gamma baked in. Adding/modulating these textures don't result in "physically accurate" images, but works good enough for the games they're used for.

If you want architectural preview quality, you probably want a 16-bit-per-component framebuffer, and you probably want some way of automatically controlling exposure/gain the same way the eye does as it moves between different lighting situations.


[This message has been edited by jwatte (edited 03-09-2002).]

Siens
03-10-2002, 12:42 AM
Do you want to use dinamic lightning? If you do not then you need light map. The multipass additive lighting algorithm gives you shadow... wow. Would be nice http://www.opengl.org/discussion_boards/ubb/biggrin.gif
After the prerendering the lightmap you can use it in real time rendering with simple multitexture function. Without shadows ... the lights can not be so realistic (for me).

Jambolo
03-10-2002, 01:28 PM
Originally posted by Morglum:
Hi !

Suppose that I want my opengl scene to be lighted by a 5000 Watt floodlight. How do I tell this to opengl ?
I mean, how do I convert a physical intensity, expressed in Watts (or any physical unit you like) into parameters to pass to glLightfv ???

Btw, is opengl's lighting model accurate enough for realistic physical-based simulation ?

Morglum

You need to look at the OpenGL specs describing how lighting is implemented and compare that to how the physics actually works. That is the only way you can decide if it is good enough.
All rendering systems take many many many shortcuts -- no shadows, no reflection, limited dynamic range, RGB, "point" sources, "directional" sources, "spot" sources, ...

zeckensack
03-10-2002, 07:32 PM
Well, actually OpenGL's light model is quite realistic. The culprit is of course that OpenGL only renders stuff, so it knows nothing about your scene. If you want shadows, reflections, refractions, radiosity, all the stuff that concerns more than one face at a time, you have to start looking at your scene yourself.

Morglum
03-11-2002, 01:03 AM
Thank you very much http://www.opengl.org/discussion_boards/ubb/smile.gif
You've solved nearly all my problems. There remain only some questions :

jwatte, as you know, ordinary 3d hardware does not support 16bit color components. Are you saying that I should require the user to have a $2000 opengl accelerator board ?

And do you know where I could find documentation on the correspondence
physical intensity <---> computer graphics intensity ?

Thanks again
Morglum