Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


More than GL_LIGHTn lights?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 Drag0n   Members   -  Reputation: 186

Like
Likes
Like

Posted 09 October 2001 - 05:54 AM

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..."

Sponsor:

#2 ANSI2000   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 October 2001 - 09:45 AM

In the standard windows implementation no. But through the xtensions of your videocard it might be possible...

#3 Scarab0   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 October 2001 - 09:55 AM

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

#4 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 09 October 2001 - 09:55 AM

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!]

  • #5 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

    Likes

    Posted 09 October 2001 - 10:01 AM

    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

    #6 mittens   Moderators   -  Reputation: 1315

    Like
    Likes
    Like

    Posted 09 October 2001 - 02:07 PM

    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

    #7 MENTAL   Members   -  Reputation: 382

    Like
    Likes
    Like

    Posted 09 October 2001 - 11:33 PM

    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 30

    CLight 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[i] = calcDistance (Obj->Pos, &Lights[i].Pos);
    }

    // Now sort the distance values from lowest to highest.
    // when swapping values about, remember to swap the LightID
    // values too, example:
    //
    // LightDis[3] = LightDis[4];
    // LightID[3] = LightID[4];
    //
    // that way we know that the 5th light (remember we start
    // at zero) is now located in the 3rd position.

    GLSetLight (GL_LIGHT0, &Lights[LightID[0]]);
    GLSetLight (GL_LIGHT1, &Lights[LightID[1]]);
    GLSetLight (GL_LIGHT2, &Lights[LightID[2]]);
    GLSetLight (GL_LIGHT3, &Lights[LightID[3]]);
    GLSetLight (GL_LIGHT4, &Lights[LightID[4]]);
    GLSetLight (GL_LIGHT5, &Lights[LightID[5]]);
    GLSetLight (GL_LIGHT6, &Lights[LightID[6]]);
    GLSetLight (GL_LIGHT7, &Lights[LightID[7]]);
    }
    ----------------------------------------------------------------

    or something like that anyway. hey, i never said it was a particulally good article .


    MENTAL


    Edited by - MENTAL on October 10, 2001 6:36:04 AM

    Edited by - MENTAL on October 10, 2001 6:37:16 AM

    #8 Drag0n   Members   -  Reputation: 186

    Like
    Likes
    Like

    Posted 09 October 2001 - 11:35 PM

    Thx @all!

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

    Drag0n

    #9 Vlion   Members   -  Reputation: 151

    Like
    Likes
    Like

    Posted 10 October 2001 - 04:59 AM

    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

    #10 Pav3   Members   -  Reputation: 122

    Like
    Likes
    Like

    Posted 11 October 2001 - 12:30 AM

    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.

    #11 benjamin bunny   GDNet+   -  Reputation: 838

    Like
    Likes
    Like

    Posted 11 October 2001 - 05:46 AM

    This question has popped up a few times on these boards before.MENTAL pretty much nailed it. You never need more than 8 lights on one particular mesh, in fact, 8 is usually too much because of the huge slowdown you get with multiple lights. For instance, FPS with 8 lights is usually about 10% of that with 1 light. If you really feel you need 8 lights acting on a particular polygon, use static lightmaps or devise your own software lighting solution (as in Quake2).

    www.elf-stone.com

    #12 MENTAL   Members   -  Reputation: 382

    Like
    Likes
    Like

    Posted 11 October 2001 - 10:52 AM

    i rule


    MENTAL

    #13 mittens   Moderators   -  Reputation: 1315

    Like
    Likes
    Like

    Posted 11 October 2001 - 01:15 PM

    No I rule... End of story.

    ------------------------------
    Trent (ShiningKnight)
    E-mail me
    ShiningKnight Games

    #14 MENTAL   Members   -  Reputation: 382

    Like
    Likes
    Like

    Posted 12 October 2001 - 01:25 AM

    Trent, are you stalking every thread i post on?!?!?!

    oh yeah, you have to - you moderate this forum.

    there goes my conspricicy theory .

    MENTAL

    #15 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

    Likes

    Posted 12 October 2001 - 08:51 AM

    I''m not sure for platforms other than MSVC/Win32, but the MSDN docs say that GL_LIGHTn is guaranteed to be GL_LIGHT0+n. You can query the maximum number of lights by doing:

    int numOfLights = 8;
    glGetIntegerv (GL_MAX_LIGHTS, &numOfLights);

    Still, as has been said by others: don''t use that many lights anyway...





    Old topic!
    Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



    PARTNERS