   Light Question
  I have a map editor, and want to add lighting to it. Thus far it displays lots of polygons with textures, but lighting isn''t implemented at all. I read that with OpenGL there can only be 8 lights, which leads me to my question. What do I do if I dont want a limit to the number of lights? I need to be able to add as many as needed.  
  Use Lightmaps (mulit-texture (or overlay) each poly with your required light)Or if you wanted to use hardware accelerated lights, for each poly (or room/zone/whatever) have the eight closest lights and then change the lights whenever you draw a diffrent poly. There is nothing stopping you changeing lights between polys.Just remember that lights only affect the vertecies of each poly.  Do not meddle in the affairs of moderators, for they are subtle and quick to anger.ANDREW RUSSELL STUDIOSCool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA | LiT | H*R ]Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Go FAQ yourself ]    ;  Or you can create your owne light object.Pass all your polygone in a loop and for each polygone calcul de result a each vertex. You can create a dynamic list of your list and have infinit lights.ex:struct dk_Light{   float r,g,b; //0 to 1   float x,y,z; //Position of the light   float Range; //The range. For attenuation}And then for each vertex you calculate the distance between light and your vertex. Make a poucentage % of the distance and the range and add r,g,b color of the light on your vertex.Vertex.r = light.r * %Vertex.g = light.g * %Vertex.b = light.b * %( this is just a little help, the concept is more complicated, and for realistic lightning, use Normals )  ;  Thanks for the suggestions, epecially the last one (gave me a bunch of ideas).However, should I use lightmaps, I have a few questions.1) Lets say I have a light in the middle of a room made up of lots of polygons. How can I generate lightmaps for all the polygons based on the light? Similar to how UnrealED and WorldCraft work.2) How much memory would a large scene (high poly count) require with lightmaps? Much more?3) Has anyone done this that can tell me what diffuculties they came across. Or know of a decent tuorial that explains how to dynamically generate lightmaps?  ;  1) http://polygone.flipcode.com/tut_lightmap.htmThat contains all you need to do simple Lambertian point-lighting.2) It depends on how high-resolution you make your lightmaps. An RGB scene will be 3 times more memory intensive than a greyscale one. Remember that you''ll have a lightmap for every face, so if you have a very high-poly level and you have high-resolution lightmaps, you''ll use a lot of memory.3) By dynamically generating lightmaps, I assume you mean in real-time. Generating lightmaps in real-time every frame is very, very slow, and gets slower for every extra light you have. So, you''d want to check to see whether the surface needs its lightmap updating (by checking if a light has moved since the last update, and checking that the light being checked is within a suitable distance of the surface) and if so, update it, otherwise leave it be. This may give you leeway to do bump-mapping too, perhaps via a fragment shader.  ;  >>2) How much memory would a large scene (high poly count) require with lightmaps? Much more?<<usually lm''s are stored with less quality than normal textureseg quake3a uses IIRC 5-6 (or less) 128x128 RGB textures for the WHOLE levels lightmaps    http://uk.geocities.com/sloppyturds/kea/kea.htmlhttp://uk.geocities.com/sloppyturds/gotterdammerung.html  ;  Yeah, I guess that a 16x16 lightmap can safely be mapped on a 128x128 poly. While having prerendered lightmaps works nice in a game with a small playable area (such as Quake 1&2&3), I don''t think it will work on BIG, outdoor areas...  ;  Lightmap in real time is IMPOSSIBLE.Take my engine, to calculate the lightmap (shadow and everything) with a resolution like in QuakeIII, it take 20min for 3000 polygones. So, .01 frame per minute. Humm.. not bad, but I prefer 60 to 90 frame per seconde. lol    DUK engineTroa Technologies.(3d game development)  ;  No, no, no, I didn''t mean in real time. Sorry for not being more specific. Basicaly, when in the editor mode, I would click a button and it would calculate all the lightmaps and apply them. Thats waht I''m talking about.  ;  Ya, I understood. It was just a joke. hehe haha hoho. ok..Yo, I want to see your map editor. Get my ICQ number : 92921263I''ll show you my engine. I calculate perfect lightmap.    DUK engineTroa Technologies.(3d game development)  