Shawn Hargreaves Blog
Question: what important things do photographers and cinematographers know about lighting?
Question: why does BasicEffect support exactly three lights?
Answer: the standard lighting rig!
Many years ago photographers discovered that a single light was not enough to make their subjects look good. Instead, they use three.
The key light is the brightest, and provides the main illumination and shadows. This will typically be positioned to match a real light source such as an overhead lamp, a window, or the sun for an outdoor scene.
The fill light is dimmer, and usually angled at 90 degrees to the key. This is used to soften the shadows, adding shading and definition to areas that would otherwise be solid black.
Finally, the back light is positioned behind the character, facing toward the camera. This illuminates only the silhouette edges, helping the character stand out against the background.
Pretty much every movie ever made and every fashion shot ever photographed have depended on this lighting rig. There are many variations:
But the underlying principle is always the same. Things simply look better when lit this way.
In the XNA Framework, the BasicEffect.EnableDefaultLighting method sets up this standard lighting rig for you.
Here is a character illuminated by only the key light, shown with textures on the left and untextured on the right. Note how the shadowed areas are excessively dark and lacking in definition:
Next, here is the fill light. Note how this illuminates exactly the same areas that were most shadowed by the key:
Finally, here is the back light shown in isolation. Subtle, but important!
Putting all three lights together, here is the character using BasicEffect.EnableDefaultLighting. Note how detailed he looks compared to using only the key light, and how everything is well illuminated while still giving a good impression of shape and depth:
For a real game you will probably want to control the lighting yourself rather than just relying on these defaults. You might want to adjust the key to match a light source object in your game world, or to move the back light so it matches your camera position, or to tweak the light colors and intensities.
Don't get too hung up on being 100% realistic. The fill and back lights in particular are intended to make your model look good: it doesn't matter whether they correspond to a real light source in the game world, or even if they're coming from a direction where it would be physically impossible to have a light source. Cinematographers position these lights wherever they like with little regard for realism, and if it works for movies, most likely it will look good in games as well!
If you are rendering realtime shadows, you will typically only want to cast them from the key light. Trying to shadow the fill and back lights isn't usually worth the processing power, and will often just muddy the image (cinematographers sometimes even use soft area lights specifically to get rid of these secondary shadows).
Although this lighting rig was designed for characters, it works well for any kind of 3D entity. It isn't really suitable for backgrounds or landscapes, though: those are a whole different kettle of fish.
Shawn Hargreaves gives us a simple run down on a Standard Lighting Rig … Question: what important things
I don't know about everyone else, but usually the first thing I do after loading models is loop over
Thanks for your article about the lighting rig in XNA.
Theory is more important than other things, I think.
Shawn Hargreaves gives us a simple run down on a Standard Lighting Rig … Question: what important things do photographers and cinematographers know about lighting? Question: why does BasicEffect support exactly three lights? Answer: the standard lighting
I know, this article is old ... Hope you see my comment nevertheless.
I am pondering about the following: Let's say I don't use just one model but 100 e.g. For every of this model I do enable the standard lightning rig with BasicEffect.EnableDefaultLighting() before rendering. Does this mean, my 3D scene has 3 * 100 = 300 lights in it? Quite heavy, isn't it? Wouldn't it be better to have just 3 lights for the _scene_ and not per object?
But what I think is strange about it: I built a little test app with 100 3D objects, all with EnableDefaultLighting(). I thought the more objects I add to the scene the more light would be in there. So, the lights of object 1 also influence object 2 and so forth. But this seems not to be the case if I look at my app.
I built the same situation with WPF and Viewport3D and so on. First, all of my objects had _one_ own directional light. If I add more objects the lights of these objects also influence the other objects (which was supposed to be) and all objects became brighter the more objects were in the scene.
Why isn't that the case in XNA?
Thanks a lot for you help!
The XNA Framework is an immediate mode drawing API. It just draws whatever you tell it to draw in the order you tell it, without trying to keep track of any larger scene information (if you want that kind of behavior, you need to code it yourself). So when you set lighting properties on an effect, this only affects objects drawn using that specific effect. BasicEffect supports a max of three lights, so if you want more than three lights on a single object, you would need to write a custom shader to do that.
thanks a lot for your answer!
I quess I didn't explain my problem very well. :-) So, when I have one model with one basic effect, I have a max number of 3 lights. But when I have 100 models, each with a basic effect, I would have max 300 lights in this scene, right?
I now wonder, why this huge amount of lights do not brighten the whole scene, why each of the 3 basic effects light only effect their model and don't emmit light to the other models?
I hope it is more clear now what I want to ask. Sorry fpr my bad English, it isn't my native tongue ... :-/
There isn't really any such concept as a "scene" in XNA. You just draw a bunch of different things, one after another, and the "scene" is just the combined result of whatever it is that you drew.
So when you draw 100 models, each one using three lights, that is just three lights per model. Lights that you set when drawing one model have no effect when you later draw an entirely different model using different light settings.
sorry for my late reply. :-( I think I get it now. So thanks a lot for your patience and help!
sorry to be commenting on such an old thread, just wanted to thank you for the visual explanation of the 3 lights & lighting rig, very useful!
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I will be subscribing to your feed and I hope you post again soon. Thanks!