Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Simple lighting questions

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2001
    Location
    Virginia
    Posts
    6

    Simple lighting questions

    Are OpenGL calculations regarding dynamic lighting dependent on (or affected by) the camera? ie Does moving the camera require OpenGL to recalculate all the dynamic lighting equations?

    And are there any solutions which fall between the computationally intensive per-frame lighting calculations versus the size-intensive per-polygon lightmap? I'm more limited on space/bandwidth than I am on computational power... I'm looking for as many values that I can precalculate as possible (ie polygon normals, vertex normals, etc, which I already do) to help the lighting system along without taking more than a few extra bytes (~50 bytes) per polygon.

    Thanks!

  2. #2
    Junior Member Regular Contributor Roderic (Ingenu)'s Avatar
    Join Date
    Mar 2000
    Location
    Horsham, West Sussex, UK.
    Posts
    161

    Re: Simple lighting questions

    OpenGL recompute Ligthing each frame that's why you'd better take care of some optimisations.

    There's a tutorial about doing your own lighting at www.flipcode.com, read it and I'm sure you'll have plenty of ideas of how to mix the main idea of this article with hardware lighting.

    good luck.
    -* So many things to do, so little time to spend. *-

  3. #3
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Simple lighting questions

    If you enable lighting all calculations are done per vertex you send to the pipeline.
    OpenGL is a state machine, but it does not "know" that the world hasn't changed since the last frame, because regarding vertex states there are only the last vertex' attributes kept.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2000
    Posts
    25

    Re: Simple lighting questions

    Depends on the type of lighting.

    A quick recap:

    Two kinds of lighting (unified into one equation) are used by OpenGL, to accommodate for different reflectivity characteristics. Diffuse lighting is viewer independent, modelling surfaces that scatter light equally in all directions. Specular lighting is viewer-dependent, related to the fact that some surfaces scatter light non-uniformally. When you see highlights, it means you are looking down the direction of greatest reflection.

    Anyway, like a previous poster said, OpenGL has no idea of a scene having changed, so it has to recalcuate lighting once per frame. You may find it advantageous to calculate your own lighting, and send it down the pipeline as a 4byte vertex colour. This has the advantage that you don't need to recalculate your diffuse lighting until the relative orientation of model and light changes, and your specular lighting whenever the relative orientation of model, light and camera changes. YMMV, depending on the number of lights, and how complex you want your lighting to be.

    HTH,

    Henry

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2001
    Location
    Virginia
    Posts
    6

    Re: Simple lighting questions

    You folks are the best :-) All 3 of you contributed to my understanding of how lighting works and I now know exactly what I'm looking for.

    Thanks!

    - Jeramie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •