Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: A question about light

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2001
    Posts
    17

    A question about light

    Hi, I have a question about light.

    The number of lights used simultaneously in opengl is limited. But how can I use unlimited light source in application such as a game?

    The idea I can image is to calculate the light myself and blend it to the material, but I am not very sure the practical method used in today's game.

    I have hear something like lightmaps. I want to know more stuff about lights. Any net address or Direction?

    Thanks.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: A question about light

    To get more than 8 opengl lights all you have to do is just reuse them. Lightmaps dont use opengl's lighting code at all. Its just an extra texture that is modulated on top of your base textures to give the illusion of a light being there.

    -SirKnight
    -SirKnight

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2001
    Posts
    17

    Re: A question about light

    Thank you, SirKnight.

    But as your answer, what I want to know is no other than how to calculate this "extra texture" colors and other parameters, so I can completely unlimited light sources numbers in a scene.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Location
    earth
    Posts
    204

    Re: A question about light

    Clusterisation is the only way to go!
    as SirKnight said, u must reuse the lights!!
    All that means that your scene must be subdivided in some parts/blocks and then u can get 8 lights available for a portion of the scene.. thus, this makes 'virtually' unlimited lights for your scene.. In fact, most of the time (in a cluster) 2,3 lights are enough.. Of course u can use more lights than this but it will certanly slow down your rendering!! )
    As a conclusion, 8 lights are definitely enough and it was a good choice to do so in the OpenGL implementation bcoz you're forced to find out the best case and then *only* encapsulate the vertice which should be lighted by a defined light.

  5. #5
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: A question about light

    Here's source code and an explanation of this:
    http://www.opengl.org/developers/cod...zedLights.html

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2001
    Posts
    17

    Re: A question about light

    Thank you, dorbie.That's what I am trying to find.

    Also, thank you Ozzy and SirKnight, but I think eight lights is far less enough to render a "really realistic scene".|-)

    Regards,
    Zw

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    806

    Re: A question about light

    If you really want more than 8 dynamic lights on a surface at once, you can use multiple passes. You can do eight lights per pass -- you add all the lighting passes together first, and modulate with the textures afterwards.

    It adds up to one pass per eight lights, plus one for the textures. Specular lighting further complicates the matter, but it's still pretty easy to do.

    -- Tom

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2001
    Posts
    17

    Re: A question about light

    Hi, Tom Nuydens

    Let me try catch on your idea. Do you mean to accumulate the lights effect and modulate it with the textures at one time. And again and again to repeat it on the each new material color until numbers of lights I want reach?

  9. #9
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: A question about light

    He means a first pass which draws 8, then subsequent passes, each of which can add another 8 lights and they are accumulated in the framebuffer with a glBlendFunc(GL_ONE, GL_ONE).

  10. #10
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    France
    Posts
    28

    Re: A question about light

    Zw, maybe you did not fully understand that 8 lights is the max for a single poly in your scene. That means 8 lights simultaneously, so you have to know which poly is lit by which light.

    Suppose you have a ground split into 4 meshes, and each part is only lit by 7 different lights (that's 28 lights), then when rendering the first part, you only need to activate the corresponding lights. When rendering the 2nd part, you'll reuse the old lights and reassign some new values to make them correct for your 2nd ground mesh. And so on ...

    Hope this helps a bit, Lolo

Page 1 of 3 123 LastLast

Similar Threads

  1. question about light prepass and msaa
    By Keith Z. Leonard in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-08-2009, 06:53 PM
  2. newbie light question
    By Mickey_dup1 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 04-26-2006, 07:31 PM
  3. Light positioning question
    By Faze in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-24-2005, 10:35 AM
  4. spot light question
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-30-2004, 11:27 AM
  5. question about light
    By suhu in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-08-2002, 03:37 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