Light-emitting objects

I’m just starting to look at OpenGL. I’ve seen that it generally consists of describing a scene of objects, illuminated by up to 8 light sources external to themselves.

What about objects that make their own light?

In the simplest case there are point-like bright objects that don’t significantly illuminate other objects, like stars and fireflies. More generally there are objects like lamps and flames.

Can OpenGL do stars and fireflies? Can it do lamps and flames?

I think 8 lights is a guideline, not necessarily a limit.

Typically, lights are not represented as physical objects. You might put a light inside a plain white object to create the illusion of a light source, but really lights are invisible things that contain intensity, color, position, etc. You would use these values in a shader to illuminate objects in the scene.

Anyway, to do something like a star I would just use white points or a white sphere. This should be fine if you don’t want them to illuminate anything. If you want a lamp, you should put a light inside a lamp-shaped object. If you wanted to be fancy you could make the light a spotlight (you would need a light direction and special functionality/math in your shader to simulate this).

Hope that helps.

Yes, that’s true for the legacy OpenGL. But 8 lights is quite high value. It should be kept as low as possible, or you’ll get a slide-show instead of a fluid animation. In most of the cases, one light source is enough. The three light sources is maximum even for some very realistic indoor scenes. Other lights sources are simulated (and baked in a texture) if needed.

The objects are illuminated by the light sources. The light sources don’t have physical representations. In order to make illusion some object emits light set its emission component to some high value and set light source at the same position.

No. Stars as well as fireflies are miracles of Nature. :wink:
But, OpenGL can help you to visualize them. Please, before asking such questions take a look at astonishing scenes generated using OpenGL API.

My advice: Before delving deeper into OpenGL take some good general book about computer graphics, or at least OpenGL Programming Guide (aka Red Book). The Red Book is a bit deprecated considering OpenGL, but it is still valuable source for learning graphics. And it is great for learning legacy OpenGL.

You can simulate that kind of lighting by placing a point light at your flame or light bulb or insect.

But it sounds like what you are interested in is a radiosity renderer which handles “area lights” very well.

GL is just a forward renderer. You can simulate “area lights” by placing a lot of point lights nearby.
And no, GL doesn’t do just 8 lights. Move into the world of shaders.

Just to clarify V-man’s first statement. I think he meant that old “fixed-function” pipeline OpenGL (“legacy OpenGL” in Aleksander’s terms) is just a forward renderer.

But of course in modern OpenGL (shaders) you can do forward and deferred rendering, GPU ray tracing, and all sorts of cool stuff. With deferred for example, you can apply hundreds or thousands of point light sources, potentially using them to approximate area light sources if you want, though if your scene is static you may prefer a precomputed approach.