More than GL_LIGHTn lights?

Started by
13 comments, last by Drag0n 22 years, 6 months ago
Is there a way to have more lights in the scene than the standard 0-7? In the Red Book is explained that the number of light sources may vary depending on the particular implementation. But that''s not what I mean. So, is there a way to have more than 7 lights? For example, 20? Thx Drag0n "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..."
-----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook"...nobody ever accused English pronounciation and spelling of being logical." -- Bjarne Stroustrup"...the war on terror is going badly because, if you where to compare it to WWII, it's like America being attacked by Japan, and responding by invading Brazil." -- Michalson
Advertisement
In the standard windows implementation no. But through the xtensions of your videocard it might be possible...
AFAIK it is possible to do this by:
1) using vertex shaders that can handle any number of lights
or
2) rendering with the standard OpenGL pipeline using multiple passes
Dirk =[Scarab]= Gerrits
That''s how many lights are guaranteed to be rendered in hardware by any standard OpenGL implementation. If you use more, it may fall back into software rendering. Just remember a couple things:
  • Most objects won''t look any different when you have 7 lights compared to 20. Pick 7 or less that are the closest.
  • You can always write your own lighting ruitines.

    [Resist Windows XP''s Invasive Production Activation Technology!]
  • Well, you should be a bit more creative and do it with a max of eight lights, you could do the following: make your 3D engine/level design so that you can see no more than eight lights at the same time. Make your own light class and copy its parameters onto the OpenGL standard lights that are visible...
    Or you can do this (a lot harder): Make an omni light (say LIGHT0 or something) and let it be the sun (place it high, huge attenuation, etc) and precalculate the shadows and map them over the scene, if you need any RT lights use the other seven...

    Personally i''d go for the first option, ''cause its a lot easier :-)

    Hope this helps...

    The Jaguar
    I''ve been thinking about this kind of stuff a lot lately... Here are my two.. or three... or maybe even four cents.

    - First of all, I wouldn''t recommend going above the 8 light limit that OpenGL provides. You risk some slowdown on cards that don''t support more than those 8 lights.

    - Second of all... Why use OpenGL''s DYNAMIC hardware accelerated lights for lighting a static scene? Its craziness I tell you. Generate a radiosity solution, or lots of light/attenuation maps, and light the freaking scene!

    - I would strongly suggest making a singleton OpenGL hardware light manager (to manage the 8 available lights that you are almost guaranteed), and use those lights for things that are completely dynamic (like lighting a missle trail) and such. And then use lightmaps for things such as, sun coming through a window, ceiling lights, etc.

    I am doing research on all the types of lighting available right now, I will then weigh each types pros and cons. Then work on an implementation for my engine... Once thats done I''ll work on a nifty tech demo, and write a nice long tutorial on everything I learned, and implementating light!

    ------------------------------
    Trent (ShiningKnight)
    E-mail me
    ShiningKnight Games
    after many hours of searching, i still couldnt find the link i wanted. damn flipcode changing everything around. it basically went like this (i think).


    you have 8 lights to play with. instead of using 8 lights for the whole scene, use 8 lights per object (how you define an "object" is up to you). when you come to render the object, enable the 8 lights that are closest to it, and render the object. then move onto the next object, enable the 8 lights that are closest to that object, render, and repeat.

    it doesnt matter what order you plug your lights into the GL_LIGHTi definitions. example:

    ----------------------------------------------------------------
    struct CLight{    CVector Pos;};struct CObject{    CVector Pos;};#define LIGHT_NUM 30CLight Lights[LIGHT_NUM];void CalcLights (CObject *Obj){    int i;    float LightDis[LIGHT_NUM];    int LightID[LIGHT_NUM];    // != should be "less than" but the forums thing its an     // html tag     for (i = 0; i != LIGHT_NUM; i++)    {        LightID = i;        LightDis = calcDistance (Obj->Pos, &Lights.Pos);<br>    }<br><br>    // Now sort the distance values from lowest to highest.<br>    // when swapping values about, remember to swap the LightID<br>    // values too, example:<br>    //<br>    // LightDis[3] = LightDis[4];<br>    // LightID[3] = LightID[4];<br>    //<br>    // that way we know that the 5th light (remember we start<br>    // at zero) is now located in the 3rd position.<br><br>    GLSetLight (GL_LIGHT0, &Lights[LightID[0]]);<br>    GLSetLight (GL_LIGHT1, &Lights[LightID[1]]);<br>    GLSetLight (GL_LIGHT2, &Lights[LightID[2]]);<br>    GLSetLight (GL_LIGHT3, &Lights[LightID[3]]);<br>    GLSetLight (GL_LIGHT4, &Lights[LightID[4]]);<br>    GLSetLight (GL_LIGHT5, &Lights[LightID[5]]);<br>    GLSetLight (GL_LIGHT6, &Lights[LightID[6]]);<br>    GLSetLight (GL_LIGHT7, &Lights[LightID[7]]);<br>}<br></pre><br>—————————————————————-<br><br>or something like that anyway. hey, i never said it was a particulally good article <img src="smile.gif" width=15 height=15 align=middle>.<br><br><br>MENTAL    </i>  <br><br>Edited by - MENTAL on October 10, 2001 6:36:04 AM<br><br>Edited by - MENTAL on October 10, 2001 6:37:16 AM    
    Thx @all!

    I think the idea is good to use only the number of lights provided by the OpenGL implementation.

    Drag0n
    -----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook"...nobody ever accused English pronounciation and spelling of being logical." -- Bjarne Stroustrup"...the war on terror is going badly because, if you where to compare it to WWII, it's like America being attacked by Japan, and responding by invading Brazil." -- Michalson
    What I suggest is writing a static vertex-shader light class,
    then have a dynamic ogl light class.
    Thats what I think I am going to end up doing.
    I`ve already got a fairly simple OGL light class.
    I can send you the code and help you out if you like
    ~V''lion

    I came, I saw, I got programmers block.
    ~V''''lion
    ~V'lionBugle4d
    what about Per Pixel Lighting?

    I know only ATi Radeon and above can do it at a reasonable speed (i own a radeon), but i have no idea how to implement it...
    It looks a WHOLE lot better than per vertex lighting...
    so maybe it''s worth implementing...(i am not sure though how many light sources it allows..but because it works on texture space, it may be a lot more than 8...i might be wrong though)

    (can anyone PLEASE point me to how to do that? iv''e been looking for a long time and all i found was DOT3 bump mapping (which is also a way of per pixel lighting, but I wanna know how to do the lighting itself..not bumpmapping...)
    PLEASE help if you can.
    **> ATi Rules! nvidia doesn''t...that simple! <**

    This topic is closed to new replies.

    Advertisement