Advanced Lighting Tips



Brush models (Bmodels for short) include things like doors, trains, platforms, and breakable brushes - basically anything that can be moved or destroyed in the game (usually preceded by FUNC_ in the editor). Lighting and visibilility for these objects are calculated differently, since they can be moved about or destroyed. Usually they don't cast shadows (otherwise the shadows would remain behind after they moved or disappeared), and often polygon faces that aren't directly lit will appear black (since bounced light won't normally show up on Bmodels). This problem is usually noticed on doors, since the edges of the door will have been up against other brushes when the lighting calculations were made during map creation. When the door opens, the edges that were flush against solid brushes will still have the lighting values they had when the door was closed (that is, completely dark).

The easiest way of avoiding this problem is to set a value for the _MINLIGHT field. This determines the minimum amount of light 'reflected' by the surfaces of the Bmodel. If a light source is nearby that provides more light than this, then those brush faces that face the light will be brighter than the minimum value. However, brightness will never drop below the minimum value, preventing completely black brush faces. I find that a _MINLIGHT value of around 0.25 stops the Bmodel from appearing to 'glow in the dark' too much.

Using _MINLIGHT is preferable to giving the entire brush a light value via the texture flag menu, since although Bmodels usually won't cast shadows, they WILL give off light. So if a breakable brush is up against a wall, and is giving off light, when it is destroyed its light is still visible on the wall it was up against. Using a _MINLIGHT value instead means the Bmodel won't give off light - it simply appears to be reflecting it (even if there is no light source nearby).

The radiance tool called ARGHRAD allows you to simulate sunlight (ie. parallel light rays). The advantage of this is that in outdoor areas, all shadows will point in the same direction. It is also much easier than trying to position several lights, as just a few values in the WORLDSPAWN entity take care of all outdoor areas that are in direct line of sight from a sky texture.

It is as easy as setting a light value via the texture flag menu for the sky textures you want to give off light, then add a few new fields into the WORLDSPAWN entity. It doesn't matter what value you set the sky texture light to - as long as all sky textures that you want to give off sunlight have the same value (a value of more than 20 is recommended - I tend to use 100). The value itself is not used to determine the strength of the light; just which surfaces the sunlight appears to be coming from. Here is an example:

FieldValueExplanation
_sun_light400Strength of light
_sun_color1 1 1RGB colour of direct sunlight
_sun_ambient48 48 48RGB Colour of ambient light
_sun_vector16 -16 -32X Y Z vector for sun angle
_sun_diffuse150 150 150RGB colour midway between Ambient and Direct light
Values that are greyed out are descriptions only, and aren't added into the WORLDSPAWN entity. Placing these fields and corresponding values into WORLDSPAWN (and having sky textures that give off light) will create white sunlight slanting down from the north-west at a high angle (just about where the sun appears to be in the Desert sky texture). Ambient light is what lights up brushes in shadows that don't get direct sunlight, but are in direct line of sight with the sky that gives off the light. It approximates the back-scattered light given off by the sky itself. Diffuse light helps to blend patches of direct sunlight with patches of ambient light; it should be roughly midway between the colour of the sunlight and the colour of the ambient light. The vector controls the angle from which the sun shines, and is respective of the origin. In this case, the sun shines 16 units in the X direction (EAST), -16 units in the Y direction (SOUTH) and -32 units below ground level. A value of 16 -16 -16 would have the sunlight shine down at a 45 degree angle. A value of 16 -16 -32 means the sun appears to be shining from higher up in the sky (so shadows won't be as long). I tend to use multiples of 16, although a vector of 8 -8 -16, or 1 -1 -2, would be identicle to this one.

The sunlight only affects areas in direct line of sight of a sky texture giving off light. If you had a cave that joins to an outside area, a tongue of faint ambient light would extend for a short distance into the cave itself, but any floors or walls inside the cave that can't 'see' the sky textures directly will not be lit (not even by ambient light). So indoor areas will need to be lit separately, or will be completely black. If, however, the sun angle shines directly into the cave mouth, then a long narrow strip of direct sunlight will extend into the cave.

For more detailed information, see the Radiosityland Arghrad Manual. The online manual is for version 3.0, which can be downloaded here. An older tutorial is also available at the old Radiosityland website (although the file links to arghrad don't work).

One very cool feature of ARGHRAD sunlight simulation is the ability to have a map change from night to day. By placing a _sun_style field in the WORLDSPAWN, and giving it the same value as the targetname of a light (that starts off), when you trigger the light you will turn on the sunlight as well. This means you can actually have the sun rise at some point in the map! The sky won't change though, so you might want to use a dawn sky. Give the light entity a small light value (100 should do) and place it close to the sky so that it doesn't add anything to the map itself. Before 'dawn', any part of the map in direct sight of a light-emitting sky texture will only be lit by the diffuse values. After triggering the light, strong sunlight will appear wherever it should normally. By triggering a func_train with a path_target that uses the CROW.WAV sound under /sounds/weapons/ in the PAK, you can herald the arrival of the sun with a rooster crowing.

ARGHRAD also allows for phong shading, which attempts to simulate the way light and shadow would appear on a curved surface. Simply give the group of brushes you want to have smooth shading a VALUE in the face flags, without checking the LIGHT or ANIMSPEED fields. ARGHRAD will automatically apply phong shading to that group of brushes. Give each separate group of brushes a different value. The value itself does nothing - it is just an ID number to distinguish between different phong-shaded brush groups.

Using phong shading, you can make columns look more rounded than they actually are. In fact, a simple five-sided column will look almost cylindrical using phong shading. Instead of each face having the same light value right across its surface (with obvious differences where faces meet), the shading will be blended across each face to help eliminate the face edges.


Previous Page | Main Page | Next Page