Advertisement

LightModels?

Started by September 27, 2000 03:50 PM
6 comments, last by Korihor 24 years, 1 month ago
I was looking through the GL.H header file, and noticed a few definitions that caught my interest: GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE What do these definitions do? Is there some way to specify a model as a light source? If so, can somebody give me some pointers on where to get more info? Thanks, Korihor
Korihor,

Those are parameters for glLightModel*() which as I understand it, defines the global ambient light and viewpoint for lighting calculations. That''s about all I know on that as I am fairly new to OpenGL.

You might want to check out the OpenGL Programming Guide by Addison Wesley for a detailed explanation of that topic

Advertisement
Ok, there is a way to specify an object as a light source, but that''s not it...

Those do... (when passed to glLightModelfv(...))

GL_LIGHT_MODEL_AMBIENT - use ambient (global) light to light the scene...

GL_LIGHT_MODEL_LOCAL_VIEWER - the viewer is local... meaning that the light is emitted from the camera ... I think.

GL_LIGHT_MODEL_TWO_SIDE - this lights two sides of a single polygon if the second face is not culled... This way you will not have to specify two normals.

... To make an object emit light, pass GL_EMISSION into glMaterialfv(...) instead of GL_AMBIENT or GL_SPECULAR or whatever... Then also pass the array to it that defines the object''s light properties as you would a normal specular spot light or whatever.

S.
hey, thanks for the help! I''ve got a question on emissions, though: Can you have more than 8 light sources on screen at a time? And if some cards don''t support it, will they just not do the lighting from those objects, or will it create an error? Thanks,
Korihor
I am pretty sure you can have more than eight lights... when I was beggining OpenGL i never payed much notice about this when I found it .

These are clips form the OpenGL superbible....

...This will range from 0 to GL_MAX_LIGHTS (8 for Windows NT and Windows 95)....

GL_LIGHT_MODEL_TWO_SIDE is specified to indicate whether both sides of polygons are illuminated. By default it is only front. 0.0 = only front, any other number is front and back. This only effects polygons, not lines, points etc...

GL_LIGHT_MODEL_LOCAL_VIEWER modifies the calculation of specuklar reflection angles, whether the view is down along the -z axis or from the origin of the eye co-ordinate system

Ambient = Light that goes everywhere
Diffuse = Bright Ligt
Specular = Light like a lazer or spot light

Hope this helps...


Is pork a noun or a verb?

Jamie
You''re right about the 0 to GL_MAX_LIGHTS, but it IS maximum light0 to light7 under winnt, win98... I don''t think there''s a way to set this maximum, and even if there were, it''s not defined in the gl headers as light8 and up... there''s only 8 lights defined...

S.
Advertisement
TIP: Compute for each object in a scene wich lights are closest and enable that lights.
This way you can have much more than those 8 lights!


(btw. There''s a demo @ nVidia that shows how to use 0-300 lights in D3D)
(btw2. Only recommended if you have a videocard that supports hardware T&L )
8 lights is the MINIMUM number supported with gl there is no maximum. (though i dont know of any consumer harware which has more ). but if youre wanting to do anything quick dont use more than 3 lights in a scene just do what richardve saiz above + take the closest/strongest ones

This topic is closed to new replies.

Advertisement