#### Where did that SUN go?
(or what you will)

If this looks ugly, then your browser probably doesn't support cascading style sheets. See the HTML only version

# CONTENTS

### Introduction

1. Just the facts, ma'am.

### You're not the only one staring at the _sun.

1. What does it do?
2. Okay, it's a sun. So what?

### That's neat. How do I use it?

1. From the beginning (_sun)
2. Shedding a little light on the subject (_sun_light)
3. How about the shadows? (_sun_ambient)
4. What color is the sun, anyway? (_sun_color)

### No fluff

1. Explain it non-verbosely

### Summary

1. What should my worldspawn look like?
2. Conclusion

### C o l o r e d lights are neat, but...

1. ...how about we not use it

# Introduction

For those of you who are using Geoffrey DeWan's version of Qrad3 (gddqrad3 version 1.03), this is going to be a real treat. If you have read the text file included with the executable, you may have noticed the mention of a sun feature. For whatever reason, everyone I have spoken to has been reluctant to try it.

Not only is the sun feature incredibly easy to use, but it also provides a lot more versatility than straight environmental lighting. Plus, it looks a whole lot better. This tutorial is dedicated to helping you get started with using the sun (you'll never turn back). It also mentions in passing another useful feature included, the -nocolor option.

## What exactly does the _sun feature do?

As you may be aware, the ability to use environment maps is a welcome improvement that has accompanied the release of Quake2. The Environment maps are pretty gosh darned cool, but outdoor lighting is only so-so.

The _sun feature allows you to chose a direction for the sun to shine, and it lets you control diffuse lighting, highlight intensity, and sunlight color. Also, from what I have noticed areas lit by large amounts of sky can qrad much faster when the area is lit by the sun instead of the sky surface. In the test map I created, qrad took 1016 seconds when the sun was not used. The same map took 509 seconds with the sun activated.

If everything is properly entered, qrad should recognize your sun without having to use command lines. This was what confused me at first, since you activate your sun in your worldspawn entity, and not at the command line. In actuality, this makes things a lot easier.

## So what's the big deal?

As you can see, outside areas look really nice, but the light looks like it is coming from everywhere. It also has a really ugly orange hue. That's not the most glaring of the things it lacks, there are no shadows!!! Well, okay, there are shadows, but they are not very well defined. The problem is, how do we get our outdoor lighting to look as cool as our indoor lighting without using a gazillion light entities and spending a couple years putting them in place? It's easier than you thought.

With a few alterations and a couple entities, a drab outdoor scene can take on a whole lot of life and personality. There are now clearly defined shadows AND highlights. With the sun activated, outdoor scenes begin to really look like they are outside. What's better, you have complete control over the color that the sun emits.

# How do I do it?

## You start with the _sun.

The first thing you need to do is to give the sun a vector. The qrad program looks for an entity that is targeted to an info_null. First, place a light anywhere inside your level (don't put it outside the level, or else you will create a leak). Target the light to the info_null that you are about to create. Now create your info_null and give it the appropriate targetname. The position of the info_null relative to the light that targets it will tell qrad the angle that the sun shines.

Add the _sun key to your worldspawn options (the same place you use to set your map's entering message). Give it a key value that is the same as your info_null's targetname. Here's an example from the .map file I used for the screenshots above.

##### "classname" "worldspawn"
"sky" "unit1_"
"message" "Map With Sun"
"_sun" "star"

##### "classname" "light"
"target" "star"
"origin" "220 -232 272"

##### "classname" "info_null"
"targetname" "star"
"origin" "192 -208 224"

###### For those of you that are confused about the Worldspawn entity. It is the place where you set all of the options such as sky, gravity, and map name. You simply add _sun to the keys.

If you have any brush faces that are on the same plane as a lit sky face, AND they faces have an unobstructed line of sight to each other, then you will get unexpected and undesirable effects. Make sure that your sky and non-sky faces are either not on the same plane, or not visible to each other. Failure to do so may cause sunlight to appear where it doesn't belong.

The final thing you need to do to make sure that your sun is working right is to give all of your sky textures a light value. Apply a light value (any light value) to all of your texture surfaces with the "sky" flag. If you do not do this, your sun may not work right.

## Light me up!

Now that your sun is in place, the hard part is done. All that is left is to set the light values. The first thing we shall do is to set the highlight value. This is the value of any surface that has a clear line of sight to the sun. Add the _sun_light key to your worldspawn entity, and give it a value. I have noticed that lower values tend to be quite dark. The screenshot above has a _sun_light value of 800.

How does this work? Well, qrad calculates the x y and z angles of the sun's direction, then checks all surfaces. From each surface, it checks if the sun is viewable at the opposite angle. In other words, the opposite angle of the sun's direction is calculated, the program checks each surface at that angle. If it encounters a lit sky, then it is not in the shadow. If it encounters a solid without the sky flag, then it is in the shade.

## How about the shade?

With highlights, there must be shadows. If the shadows were completely unlit, it would be too harsh. After all, the diffuse light of a sky emits some light, even if it is not as bright as the sun. The _sun_ambient option allows you to fill your shadows. A value of 50-200 works best for this.

For a good example of how diffuse lighting works, take a look at the shadows outside on a sunny day. If you try to emulate this, you can't go wrong.

## Setting the sun's color

To give you absolute control over your sunlight, Geoffrey DeWan included the _sun_color option. This allows you to make your sun project any color without doing any screwy texture swapping.

Simply add the _sun_color key to your worldspawn and give it a color value just like you would to a light entity (I find that 1 1 .85 works good for a medium yellow light). For a review of what your worldspawn entity should look like now, see the example.

# In as few words possible

## Using the sun feature

First, create a light and target it to an info_null. This will be your sun's angle.

Next, add the _sun key to your worldspawn, and enter the targetname of the info_null.

Make sure all of your sky textures have the light flag checked and a light value.

Add the _sun_light value to your worldspawn, and give it a light value.

Add the _sun_ambient value to your worldspawn, and give it a light value.

Add a _sun_color value to your worldspawn, and give it a value.

Run qrad3 as you normally would (make sure it's the one by Geoffry DeWan, version 1.03, or ArghRad 1.0).

## Some closing thoughts

Version 1.02 of DeWan's qrad3 used the sun, sun_light, sun_ambient, and sun_color keys. This was annoying, because they would pop up a message "sun is not a valid field" when you would run the game. Now that he has added an underscore before the keys, the error is gone, and everything is peachy keen.

The sun feature is incredibly useful. It is a definite improvement over the original qrad3 code. It is by the will of Id software that we have the source code available to improve an already great game, and by the hard work of the fans that the tools are there. Everyone should show their appreciation of the spirit of free information by not plagiarizing or pirating software.

### Your worldspawn should look something like this now:

##### "classname" "worldspawn"
"sky" "unit1_"
"message" "Map With Sun"
"_sun" "star" Use the targetname of your info_null
"_sun_light" "800" The highlight brightness
"_sun_ambient""100" The shadow depth
"_sun_color" "1 1 .85" Same as if it were a light

# How to qrad without color

If you have ever compiled a level with colored or texture lighting only to find out later that it looks a lot better without color, you can easily recompile it without having to change all of your entities and messing with your surface properties. All you have to do is add -nocolor to your qrad command line. For example, if you normally compile with this command line:

##### qrad3 -extra -bounce 40 [filename]

You just add -noclor to it and you're good to go.

##### qrad3 -extra -bounce 40 -nocolor [filename]

The light intensities may not be the same as it was when you had color, but it shouldn't change too much. Here's a little clip from the text file included with gddqrad3 version 1.03.

###### Disables colored lighting. All colored light is computed as normal, but final lighting results are converted to grayscale according to the formula that is used to compute the Y signal of a color television broadcast (which is what a black & white television displays). The colors are not weighted equally (0.299Red + 0.587Green + 0.144Blue). A green of the same intensity as a blue will convert to a brighter lightmap than the blue. Red falls in the middle.

This was written by Michael N. Meadows, AKA Ryche. My sources were as follows: Me, the text file included with gddqrad3 version 1.03, and a lot of hard work. Feel free to quote me. Feel free to steal my words and claim them as your own. Your conscience is all that stands in your way. Most important of all, however, is that you have fun.