The unreal engine gives mappers a (relatively) realistic way to create sunlight. The sunlight actor simulates a distant light source originating at infinity by having it give off parallel light rays, much as the sun does. This new light actor can light a huge area. (There is no apparent limit to the area that a sunlight actor can cover, except for the zone limit mentioned below.) More sunlight actors can be placed at the same angle to cover the rest of the map.
Think of it as a regular light actor with bDirectional=True, but on steroids (and, most importantly, parallel, instead of diverging, light rays). ;)
Gregor: Unreal 2's Sunlight actor does not appear to work the same as in UT2003 (the rays are not parallel, they diverge. It behaves like a standard light with a high radius), nor is it found in the same place in the class hierarchy (it's directly under Actor). Also, bDirectional is False by default.
- 1 History
- 2 Using the sunlight actor
- 3 Tips, Tricks and Recipes
- 4 Sunlight Problems
Prior to UT2003, outdoor maps were dificult to light convincingly, requiring many repeated and large-radius lights (obviously the larger the map, the more lights were required). Many an outdoor map, when opened in the editor, were literally carpeted with lights. While this was a decent workaround, the main problem with this was the fact that consistent shadows could not be achieved. A dawn map would have shadows going north, south, east, west, and everything inbetween due to the multiple lightsources. Alternatively, the lighting setup could kill the shadows entirely, depending on a couple of factors.
Halflife mappers were lucky, as they have had a "sunlight" lighttype to play with for years.
Using the sunlight actor
The sunlight actor will not produce any light unless you have surfaces flagged as Fake Backdropin the zone you want to light. The sunlight shines 'through' the fake backdrop faces as if it was coming from outside them, in the skybox. To avoid HOM errors from the fake backdrop surfaces, you should probrably have a skybox as well. (Though thick distance fog that completely obscures the fake backdrop surfaces would work too)
See Adding Sunlight
BSP surfaces will cast shadow onto the terrain unless its fakebackdrop
Sunlight does not cross zones. You have to place a new sunlight actor in each zone.
There is no lens flares in UT2003. See Lens Flare for an example of code that could be adapted for a mod or mutator.
Unfortunately, sunlight actors do not have a corresponding corona that adjusts position based on the camera location. That is to say, a corona on the sunlight actor (not sure if that even works) will appear to move across the sky as you move through the level. (Parrallax) You can limit the damage of this by having a very large zone and having the sunlight actor way up in the sky, but a better solution would be to script a light that would change position in real-time to adjust to camera movement.
Tips, Tricks and Recipes
Realistic Sunlight Settings
Simulate a sunny day effect on your dark interior map: Use a bright yellow-white sunlight actor shining in through windows and skylights for the direct sun effect, then add dim blue lights in each window to add a diffuse sky light. If your skybox shows bright terrain or sky features like big moons or sunset clouds, try adding point lights of the same color to simulate the diffuse reflected light from outside the map. It's basically a ghetto ultra-low-resolution diffuse radiosity effect.
Avoid Super-Dark Shadows
If you want your sun to cast shadows across your terrain you will quickly notice that it causes pitch black shadows. A second sunlight actor reversed in direction, with a much lower brightness can help bring some light to these black areas.
Real light scatters through atmospheric particles, so dawn or dusk shadows look bluish or reddish blurred. There are no light types in Unreal that create this affect.
Sunlight is usually used to light terrain. It will shadow and light BSP geometry, but there are a few glitches as of build 2166 that will need to be tweaked manually in your level. Unless your concept demands large areas of sunlight, consider using some sort of fake sunlight made from spotlights; it may work better than sunlight.
The sunlight actor can be used to simulate sunlight coming thru BSP windows into a BSP map. The effect works and is nice but can cause an unintended weird effect: many, but not all, of the corners of the BSP facing one direction may obtain a weird sunlight glow as if light was leaking under the walls. Moving the sunlight actor around or changing the angle won't help. There are no leaks; its on the lightmap.
There are several way to fix this, none of which are perfect. You will probably need to use a combination of them in different places.
1. Try tweaking the lightmap resolution on the affected surface (try both higher and lower res, I had one glitch that went away when i raised it and a diff one went away when i lowered it)
2. If you can, cover the glitches with static mesh "trim" and leave'em.
3. For the rest that don't go away after #1, or aren't hidden by #2, build a simple BSP shape (a square or tri-prism) and place it in solid space about 16UU from the bad corner. Subtract it and move it up and down until it "shades" the glowing corner from the sunlight. Since it has no connection to the real map it will be off in its own zone and shouldnt ever really be visible to the renderer.
4. Zoning/antiportal? I'm also assuming that when I start zoning this map the glitches will at least only happen in the zone with the sunlight (I hope I hope). Does sunlight shine through zone portals like regular lights?
5. Try moving the fake backdrop faces and the sunlight angle around slightly. The glows appear dependant on the angle of the sunlight and the proximity to one of the fakebackdrop 'holes'.
You may find that the glow is small and out of the way, and can be left in.
If you are looking for perfection, you may want to fake the sunlight effect with lightboxes outside each window instead of chasing the glows around and around your map.
Static Mesh Lighting Problems
AlphaOne: Quick question: I have two sunlights in my map (one is bright white-yellow, the other is blue to make shadows look better than black blobs) How come the sunlight actors don't light up my static meshes? I can see the shadows, but all static meshes are black as well!
ZxAnPhOrIaN: Rebuild lighting and make sure that you have a skybox! :P
AlphaOne: Actually I do have my sunlights in the sky box, and I have rebuilt it numerous times. However, I only see proper lightning on the terrain. All the static meshes are black!??? What do I do?
ZxAnPhOrIaN: Try moving the sunlights in the sb to the actual play area, that might help
AlphaOne: Thanks! It works.
ZxAnPhOrIaN: My pleasure... :P
Axe56: I've noticed that raising the zonelight properties, helps static meshes look more natural in their lighting.
GTD-Carthage: Sunlight makes it easier for large out-door maps. Can't the code in the sunlight actor be immitated so it can be used in an earlier version? (let's say UT99)
I'm also getting the problem where static meshes are _over_lit, but I can work around that with bSpecialLit. -Jeeptrash
Jeeptrash Theres also a weird effect where static meshes I sloppily left sticking into solid space are being shadowed to other places on the map. (which just means I need to redo it right), but it's kind of odd to see the shadow of a mesh being cast on a wall 3 rooms away at a totally impossible angle.