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!

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.

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.

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

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

Thanks!

  • Jeramie