Advanced Features

Sun

The sun feature allows you to light outdoor scenes based on directional light instead of from the surface of the sky brushes. This creates a more realistic looking outdoor light source. Using a sun will produce clearly defined highlight and shade areas, and allows you to control the color of the light produced.

Where to start?

While placing your brushes, you should keep two things in mind. First, you should apply a light value to all of your sky brushes. A value of 50 is a good number to use, but any number will do, since the sky textures do not radiate light when the sun is in use. If the value is set too low, the sky may not light, so avoid anything blow 50. Once the sky is activated, the sky surfaces will not emit light.

Second, you should make sure that you do not have any brushes that have faces on the same plane as any of your sky brushes if they have a clear line of sight to each other. If a brush has a face on the same plane but there is another brush blocking the line of sight between the two, it is okay. Brush faces that need to be lit by the sun that violate this rule will not be lit properly.

A simple workaround for this is to angle your sky brush so that it does not set flush with your solid brushes.

Define the sun’s angle

Place a light entity in the level, and target it to an info_null like you would to a spotlight. The resulting angle, from the light to the info_null, will be the angle that your sun will shine. If you have multiple suns, create multiple light-info_null pairs, one for each sun.

Whether a texture is in the sunlight or the shadow is determined from the angle that the sun shines, not from any texture to the light or info_null. Therefore, the position of the light or info_null relative to the level or to each other is irrelevant. The only thing you will want to make sure of is that both entities are contained inside the level, or they will cause a leak.

Enter the sun into your worldspawn

Use the targetname of your info_null as the value for the "_sun" key. For example, if your info_null’s targetname keyvalue pair is

"targetname" "star"

then you would enter the following value into your worldspawn

"_sun" "star"

or

"_sun_target" "star"

_sun and _sun_target do the same thing

Sun highlight intensity

To define the brightness of textures that have a clear line of sight to the sun, you must set the _sun_light keyvalue pair. Sunlight intensity does not diminish with distance. A texture is either in the sun, in the shade, or neither. To set the sun’s light value, add the following syntax into your worldspawn entity:

"_sun_light" "[value]"

Sun ambient brightness

Anything that is not in a direct line of sight to your sun, but still has a line of sight to any lit sky surface will be considered to be in the shade. Since the sky casts diffuse brightness, it would be realistic to have shade that is not completely dark. The _sun_ambient keyvalue pair allows you to define the brightness of the shadows.

This can be defined in two ways. If you use a single brightness number, the color of the shadow lighting will be derived from the average of the color of all of your suns. If you define each color brightness individually, then you can override the default color. The syntax is as follows:

"_sun_ambient" "[value]"

or

"_sun_ambient" "[redvalue] [greenvalue] [bluevalue]"

By using the latter method, you define the brightness of each of the three colors separately.

The _sun_ambient keyvalue pair is the only pair that cannot be assigned a _sun2, _sun3, and _sun4 key.

Diffusion techniques

For that area between the shade and the sunlight lies the diffused light. This is a sort of blurred area where light from the direct sunlight spills over into the shade. To simulate this, the _sun_diffuse option is available. To use it, define a value that is greater than your _sun_ambient value and less than your _sun_light value. Your keyvalue pair should resemble the following

"_sun_diffuse" "[value]"

If you want to alter the distance that it takes for diffuse light to fade, the _sun_difwait or _sun_diffade keyvalue pairs allow you to do so. Values greater than one will make the light fade faster, while values less than one will slow the rate of fade.

Note that as you increase the _sun_difwait or _sun_diffade values, you may have to decrease your -chopsky value to maintain a quality result. The _sun_difwait and _sun_diffade keys do the exact same thing. A value of 1 is default.

"_sun_difwait" "[value]"
"_sun_diffade" "[value]"

Color

You define the sun’s color the same way as you define the color of a light entity. Place the following syntax into your worldspawn entity.

"_sun_color" "[red] [green] [blue]"

Multiple suns (up to four)

Four suns,.!?

That’s right, you can have up to four suns in any given map. Defining them is easy. All you have to do is define them like you would a single sun, and substitute "_sun2" "_sun3" or "_sun4" for the "_sun" portion of any of the sun keys except "_sun_ambient".

In other words, your first sun would use "_sun" in the key, your second would have "_sun2", you third "_sun3" and your fourth "_sun4".

Alternate aiming techniques

The following methods save you from having to create entities to define the sun's angle. If you use an alternate method for aiming the sun, you do not have to use the "_sun" "targetname" keyvalue pair.

Instead of using the light-info_null pair to define your sun’s angle, you can use an angle or vector method. Using the angle method, you use two numbers to define the number.

The first number is called your yaw. The yaw is the same as the angles you use to define door direction or monster facing. The yaw range is 0-360, representing all 360 degrees on the z axis.

The second number is your pitch. This represents the angle on the horizon. A value of 0 is level with the horizon, a value of -90 is facing straight down, and a value of 90 is facing straight up. The range of pitch is -90-90 relative to the horizontal plane.

The syntax would be entered as follows:

"_sun_angle" "[yaw] [pitch]"

or

"_sun_mangle" "[yaw] [pitch]"

The keys _sun_angle and _sun_mangle are identical. To define multiple suns, simply substitute _sun2, _sun3, or _sun4 with the _sun prefix of the key.

The second method of defining the sun’s angle is by using a vector. A vector is defined by a point, relative to the origin (0,0,0). The angle that points from the origin to the x, y, and z values defined by the vector will be the angle that the sun will shine. See the section on alternate spotlight aiming for more information.

"_sun_vector" "[x],[y],[z]"
Contents
Return to Radiosityland