Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How can I use more than eight lights??

  1. #1

    How can I use more than eight lights??

    I know I have asked a similar question before but I never got the answer I needed.. how do I actually use more than eight lights. Doesn't Open GL have a fixed number of lights you can use such as Light0 to Light7 so how do you use more than 8 lights...? If someone has used more than 8 lights in a given scene (all the more than eight lights being rendered at the same time)... please post some code.

    Thanks,
    Aditya

  2. #2
    Guest

    Re: How can I use more than eight lights??

    We had the same question a week ago. Look down a bit.

  3. #3
    Guest

    Re: How can I use more than eight lights??

    more than 8 lights is not recomender, one light slow the FPS in a 23%, using dot3 lighting or lightmaps.
    look with 8 light in my scene the FPS is 24.
    Athon XP 1.4.
    GEforce 2.
    256 ddr 333.
    thinking about this.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: How can I use more than eight lights??

    You can't use more then eight light sources and you have been told that in your last message post, sorry it was not the answer your were looking for.

    You where given the answer as to how to work around this by using light maps and get more then eight lights. This is how it is done in most 3D game engines.

    Just do a search on "openGL light maps" for examples of how to do light maps in opengl.

    Yes, it would be easy if you could do it with a simple openGL statment, and light maps take a little more work.


    Originally posted by adityagaddam:
    I know I have asked a similar question before but I never got the answer I needed.. how do I actually use more than eight lights. Doesn't Open GL have a fixed number of lights you can use such as Light0 to Light7 so how do you use more than 8 lights...? If someone has used more than 8 lights in a given scene (all the more than eight lights being rendered at the same time)... please post some code.

    Thanks,
    Aditya


    [This message has been edited by nexusone (edited 10-28-2002).]

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: How can I use more than eight lights??

    Using more than 8 lights isn't recommended, but it CAN be done IF your implementation supports more than 8 lights. You check that using glGetInteger(GL_MAX_LIGHTS);

    Now, I'm assuming your question is that, assuming your implementation supports more than 8 lights, what would you use for a constant in place of GL_LIGHT8, as the default constants only go to GL_LIGHT7. The answer is that you use GL_LIGHT0 + n, where n is the number of the light you want to use.

    Again, using 8 lights isn't generally recommended and you can find older discussions for how to do things like lightmaps, or only using the closest lights instead.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    245

    Re: How can I use more than eight lights??

    You could use more lights than your GL implementation supports with multipass rendering. In the first pass, enable the first eight lights and render as usual. In the second pass, enable the next eight lights, eliminate all terms that aren't due to the light sources (fog, etc.), and render the scene again with additive blending. Sorry if I'm pointing out the obvious here.

  7. #7

    Re: How can I use more than eight lights??

    yeah sorry I asked a similar question but I got several weird vague and contradicting answers and then someone said You definitely could so I went on through the rest of the code in my OpenGL book but found the preset names you have to use for the lights...

    Thanks to all those replies.. I will look into light maps..

    -Aditya
    P.S. Sorry once again

  8. #8
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: How can I use more than eight lights??

    Another thing to consider is: WHY would you want to use more than 8 lights to light a single primitive?

    If the answer is: just so I can set up all my lights and draw all my geometry in one go... then you have some optimisation work to do

    You should consider grouping your primitives in such a way that each group is rendered with just the two or three relevant lights enabled. That will give you huge improvements in rendering speed with usually negligible loss of quality. YMMV of course.

    Just my .02

    Jean-Marc.

  9. #9

    Re: How can I use more than eight lights??

    thanks JML.. would that be something like this...

    initialize 8 lights at (x,y,z) (x,y,z)....
    draw two cubes

    initialize 8 lights at (x,y,z)....
    draw two spheres

    just pseudocode.. but how can I tell opengl that I have rendered one group of primitives and am going to render the others with their own lights?
    can you give me some pseudocode.. or better... real code.

    -Aditya

  10. #10
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: How can I use more than eight lights??

    Just set the new light parameters and draw your objects. Just like the pseudocode you wrote.

Page 1 of 2 12 LastLast

Similar Threads

  1. Speed of built in lights v.s. custom lights
    By STTrife in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-23-2013, 05:11 PM
  2. Can I use more than 8 lights?
    By AlexanderSK in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-29-2003, 03:02 AM
  3. lights and 3D
    By lara in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 11-11-2002, 07:11 AM
  4. Lights
    By PhireBat in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-07-2001, 06:13 PM
  5. Replies: 13
    Last Post: 11-29-2000, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean