# Lighting Your Maps Co-authored by Tony "Mad Dog" Ferrara You may be the best mapper. You may understand all of the mysteries of entity manipulation. You may be the God of Architecture. But if you don't understand lighting, shadows, and all the stuff in between, your maps are going to fall short. Light and shadow are elements that canvas artists devote more effort to than any other aspect of their work. Read any of the trade mags or books dealing with computer-generated 3D animations, and you'll see this subject preached time and again. CG movies such as It's A Bug's Life and Toy Story had up to 70 people working on lighting alone. Light and shadow create the mood and drama. Remember the first time you played Quake? Gone were the cartoon-ish sprites and hallways of DooM. Quake plunged you into a murky dungeon of torch-lit hallways, drawing you in to its sinister environment. The dramatic shadows made me want to tip-toe through the map, not run through it like some suicidal madman. Next to bad textures, Cranky Steve howls more about badly lit maps than anything else. Mappers will devote weeks to constructing a map, only to throw in lighting as an afterthought. Others use lots and lots of colored lighting--another Cranky Steve complaint--as a crutch, thinking that stroboscopic green lighting will cause the player's jaw to drop in awe and admiration. The opposite is true. Colored lighting should be treated like salt on food--a little will add to the atmosphere or ambience. Some mappers though, feel they've got to unscrew the cap and drown a map in colored light. In an effort to disassociate themselves from these slop artists, some mappers won't use colored lighting at all. DISCLAIMER Those of you who may have played my DooM re-creations will say, "Yo, dude--what about some of that colored lighting you were so liberal with?" In SOME cases, I referenced the DooM map editor, which did show different colored torch flames. Although the DooM mappers used them with impunity--DooM had no colored lighting-- mine are few and far between. 'Nuff said. In this tutorial, I'm going to cover the mechanics of light entities. We'll look at the use of sunlight, spotlights, and point (or 'area') lights. Texture and special effects lighting will be covered in another tute. First of all, if you're not using Tim Wright's ArghRad you need to get it now! Tim's site has tutorials that cover all of ArghRad's parameters, so I'm not going to go too much in-depth with them. The great thing about ArghRad is that you can get the same results using different methods. For example, sunlight can be set up either by using targets, or by inputting values directly. I really appreciate this approach. ### LIGHTING LIMITATIONS Due to current CPU and other hardware limitations, it's not possible to fully generate true ray-tracing within a game. Users of 3D programs are fully aware that lighting, reflection, and refraction can tax a computer to its fullest. Real-time 3D shooters can only simulate raytraced effects. Take a look at the picture here: This is an image generated in Lightwave 3D, that shows how shadows are produced using a raytracing technique called 'shadow mapping'. See how well-defined each shadow is cast onto the ground from the fence pickets? At $2,500, the shadows created by Lightwave had better look real! Now, here's a Quake2 screenshot, where I attempted to create cast shadows from a fence: If you look closely, the bars in this picture do not even cast shadows, even though they are normal world brushes, capable of doing so. ArghRad can only approximate shadows because its radiosity effects are based, in part, on light patches. See the ArghRad manual for a further explanation. What's a mapper to do? Truthfully, Quake2 was designed for fast-paced gaming, not architectural exhibition. As 3D games mature and CPU bandwidth increases, we will no doubt see more realism in games. For now, however, we can either ignore the limitations or use other means. ## The "Jaggies" & Reality Checks "Jaggies" in this context does not refer to the lack of anti-aliasing; for the purposes of this tutorial it is a term explaining the "stair-step" shadows that appear in the game. Here is a screenshot of some jaggy shadows with a -chopsky of 1024, a -choplight of 32, and a _sun_diffuse of 50. See how the shadows on the ground are "stepped"? "Canyon" sky courtesy of Primordial Soup. Here is the same scene with a _sun_diffuse of 150. Notice that the shadows are not as dark as the in the shot above. By jacking your -chop values down, you would think that the jaggy effect would be less noticeable. That's not the case, however. Take a look at the next picture. This same scene (a single "room" 1024 x 1024) was rendered with a -chopsky and -choplight of 16. Not only did it fail to smooth out the jaggy shadows, it took almost 10 hours to compile the lighting calculations! It's not reasonable to consider lowering -chop values to solve this problem as the screenshots here testify. Reality dictates that you are constructing an environment suitable for fast action and plenty of it! Players are not going to pooh-pooh your jaggy shadows, though they might groan about not having enough ammo. The effects displayed above serve to illustrate how the Quake2 engine is limited by rendering absolutely everything as defined by its rectangular world grid. As you can see, even light patches are affected. Lowering your -chop values actually sharpen the stair-stepping rather than reduce it. If you really, really want the effect of angled shadows, one approach is to work with the world grid rather than try to fight it. Sun source angles of 0, 90, 180, and 360 will not produce jaggy shadows, since they will fall precisely on the grid. You could build the environment itself rotated on the horizontal plane to produce the angle, and the shadows will appear angled to the player (when in fact it is his orientation that is actually angled). However, this would probably require painstakingly rotating textures in many cases to secure the illusion. Or, you could use the File/Load option to open your completed map, and choose Selection/Rotate/Arbitrary Rotation, and input the 'Z' angle. This will rotate the entire map. You decide if it's worth the effort or not. ## Disappearing Shadows Sometimes you may be working on a map, and tweaking your sun elevation angles, when you suddenly find yourself with a map with shadows not showing up. Here is a shot of some posts casting shadows on the ground. Nothing wrong here, right? Here's the same scene with the sun angle changed from 45 degrees to a steeper 60 degrees. What happened to the shadows?Again, we change the sun's angle to 25 degrees, which places the sun low on the horizon. Note: Now, the shadows are separated from the fence posts, making the posts appear as though floating above the ground! I point these things out so that you will know the limitations and parameters you must work within. Then, when you start seeing shadows disappearing or looking strange, you'll understand why. ## Sun Color Sense ArghRad's '_sun_color' option allows you to input number values to light your map with any color you desire. If you don't use the option, ArghRad will use an average based on the sky texture. Below is a shot where I tried to blanket the scene in--what I thought would be--an appropriate blue light: There are a few things wrong with the scene, however, as you can readily see. It's rather dark, the lava pool's red glow stands out too much to my liking, and the far door is cloaked in darkness. I used a _sun_color of .5 .5 1, which is a medium-blue, but I'm better off deleting the _sun_color option and letting ArghRad do the calculating. Don't equate sky color to sun color; our own world's sky is blue yet the sunlight bathes the earth in a yellowish white. The original Q2 maps contain skies that are almost uniformly red, yet the sunlight is still white. Here's the same scene, with colored sun light calculated from the sky texture. Notice the difference: Sky credits belong to Primordial Soup. Now the water pool stands out, and the scene has a much more vibrant appeal. Additionally, I lowered the lava's texture lighting brightness from 700 to 100. By re-positioning the sun's target, the entrance and stairs now benefit, inviting the player toward the door (and almost certain death!). ## Area Lights A map would be boring if you didn't sprinkle a few area lights around it. Before ArghRad, area lighting could be accomplished by using 'nodraw' 'mist' sky brushes in the middle of an area. If you use ArghRad's sun options, such area lights will emit sunlight (since they are sky brushes)---not too appropriate in gloomy dungeons. But ArghRad gives you alternatives which are better and easier to use (and don't require the compiling time sky brush area lights do). To avoid the extra work of installing area lighting (and some cool light prefabs), raise the ambient light level. This will ensure that your maps will be ho-hum, and b-o-r-i-n-g. Area lights must use _focus to soften shadow edges, and _fade to "squeeze" more light out of them. Note the screenshots below: This is a large, plain room, lit only with a worldspawn _ambient value of 30. See how flat and uninteresting (I.E. "boring") it is? The textures are lit with dreary sameness. The mapper may say to himself, "I'll throw in some area lights to brighten things up!" Here's the same room, except now I've added 12 non-displayed light entities, all with a light value of 100. The map now begins to take on the characteristic "cheesy" look of a rookie mapper. The entities give themselves away by casting "spot" lights onto the walls, floor and ceiling. Adding more entities is not going to easily get rid of this cheesy lighting. Besides, your map would be drowning in light entities if you tried this method. Here is the room, lit by a single light entity, with a light value of 50. You got it: 50 Some mappers believe any value less than 100 is mostly useless, and certainly no good for lighting such a large room. The key? A _focus .1 to soften the light/shadow boundaries, and a _fade .1 to force the weak light value to extend much further than it normally would. Area lights and any prefabs holding them can be as simple or as fancy as you want them to be. Here's a shot of a mine light with no values added to it. Here's the same shot, but subtlety changed with some added _fade and _falloff. Falloff values take some experimentation, as drastic results can occur. For example, the light value in this shot had to be increased from 300 to 2000 to compensate for the falloff effect. See the ArghRad manual for more info. Another way to enhance your mood is to use a mappack. Some of these have the torch and fire lights that can add a more medieval feel to your map. Below are a couple of screenshots, featuring Quake 1-style lights, using Omega Development's Mappack. Flame screenshot courtesy of Omega Development. There are a couple more areas we need to cover: texture lighting and special effects lighting. These will be covered in a separate tutorial.
Copyright 1999, by Terry DeLaney. Permission is granted to distribute this file as long as the author receives credit.