   Only Eight Lights?
  I'm not very far into lighting, but eight lights seems a bit small.  What happens in games if they're restricted to only eight lights?  This doesn't sound right.  What about if I was in a level editor and I made 30 lamps... each would have its own light source and I know it's possible, but how do they do it unless if they're not restricted to only eight?   
  Remember that Direct3D is restricted to eight lights enabled simultaneously. But, during a scene, you can turn on/off different lights depending on the object you're drawing, and then, that number becomes more than enough.   ;  When you use a shader (rather than the fixed-function pipeline that you are describing) you can do all the lighting calculations "by hand", which allows you to define many more than 8 lights at once.A basic GLSL lighting example:http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir1One example (there are many different ways) would be to completely disregard the OpenGL API lighting functions and instead pass the lights' parameters (e.g.: positions, colours, etc.) into the shader in the form of textures (e.g.: one RGB texture for position, one RGB texture for colour, etc.). In effect, passing textures into a GLSL shader like this is equivalent to passing arrays into a C++ function.The limit would then be the card's RAM size, maximum texture size, maximum texture count, and maximum shader instruction count capabilities. Either way, it's going to be a lot more than the fixed-function pipeline can handle.There's a ton of demos showing off, say, 64 simultaneous lights in a shader. Darned if I can find one right now though. My google-fu is failing me.[Edited by - taby on December 27, 2008 11:16:58 PM];  Eight lights per face, not per-scene.That said, nobody uses the OpenGL fixed function lighting anymore. As taby said, everything is done by shaders nowadays, which completely bypass the FF lighting.About the number you can do through shaders, it depends a lot on the lighting method you use. Other than through the fixed function pipeline, you are free to choose amongst a multitude of different lighting systems with shaders. On modern graphics cards, you could do thousands of small per-pixel lightsources without any major problem.  But most games use a completely different approach anyway in order to get global illumination and shadows. With PRT, for example, you can effectively get an infinite number of sources at a much, much higher quality than anything possible with standard FF lighting.;Quote:Original post by Yann LEight lights per face, not per-scene.That said, nobody uses the OpenGL fixed function lighting anymore. As taby said, everything is done by shaders nowadays, which completely bypass the FF lighting.So to learn OpenGL fixed lighting would be a waste of time? Does it at least give me an introduction to lighting?  I'm reading the OpenGL Red Book; is it really out-dated as someone from Amazon said ( Version 1.1 )http://www.glprogramming.com/red/about.html?   ;  forget gl native lighting....the limimtation only applies to that, and as said, per vertex.However, it might be usefull to read into it, in order to make your own lighting (in which you can have as many lights as you want..).But in this case, the interesting thing is only the equations used in gllighting to produce the 'effect', and these are simple and general enough.to make a vertex lit by L lights (very simply)for each vertex vfor each light l  calculate some dot/distance result for attenuation,  modulate equally for all l  and this determines the color for the vertexby enabling glLight, you do nothing more then letting GL calculate the colors for you (in a very simplistic predefined manner)   ;Quote:Original post by openglJunkieQuote:Original post by Yann LEight lights per face, not per-scene.That said, nobody uses the OpenGL fixed function lighting anymore. As taby said, everything is done by shaders nowadays, which completely bypass the FF lighting.So to learn OpenGL fixed lighting would be a waste of time? Does it at least give me an introduction to lighting?  I'm reading the OpenGL Red Book; is it really out-dated as someone from Amazon said ( Version 1.1 )http://www.glprogramming.com/red/about.html?On the contrary. The fixed-function pipeline lighting model is very easy to use, and knowledge of these basics will only prepare you better for the inevitability of shader-based lighting.In fact, you can actually still set up the lights and their parameters using the fixed-function API calls (e.g.: glLightf) and then retrieve that information from within shaders (e.g.: gl_LightSource) -- that is, if you need 8 or less lights, but still want to calculate their effect within the shader rather than have the fixed-function pipeline do it for you.   ;  You might apply many more than 8 lights using vertex shaders, but it usually isn't such a great idea anyway. Rendering with so many lights per vertex will probably make your vertex shader (either fixed or programmed) the application bottleneck (in my experience at least). So you should try to select the minimum amount of lights per rendered object in the scene.Even then, you might occasionally have an object light by more then 8 lights at once. You can do one of two things, either combine lights together using some heuristic until only 8 combined lights are left, or render the object in multipass, adding the extra lights in later render passes using alpha blending. If you intent to have many, many lights in your scene, you might look into deferred shading. Instead of selecting lights per object, the lights are 'rendered' into the scene after all objects are rendered. This method shifts the burden from CPU and vertex shader to pixel shader. This method however is not that simple to implement.Which method is best all depends on your application