Level Design By Tub

<< Back to Articles

Model Lighting Adjustment


Description: An article on how to adjust the lighting from models to suit your map.
Article Type: Technical
Author: Tub
Published: 2004-12-12


2004-01-25 - Note: Q3map2 supports a far more elegant way of remapping model shaders. Hybridesque has a tutorial on it as part of his Q3Map2 set of tutorials.

Algiers Map Have you ever seen a light model that you wanted to include in one of your maps but just found that either the lighting was too strong, too weak, or just the wrong colour? Well working on my most recent abbey update I came across this very problem. I wanted to use the casa light model in place of the existing torches. The light model gives out no light at all unfortunately.

One possible solution to the problem would be to place point light entities in front of the models. Only problem with that is I hate using them. I try to never use them for a few of reasons:

  • If you want to change the colour or brightness you have to go to every single entity an update it. It's very easy to miss one or two.
  • If you want to create a new light, move one, or delete one you need to remember to update the entity as well.
  • The lighting doesn't look realistic because of the backsplash position.

Sure there are some places were you need to use light entites but it's better to avoid them if you can.

The other solution was to create a shader for the light. Fortunately whomever made the model split the lighted and unlighted areas into different textures. Knowing that, all I needed to do was create a shader for the texture and add it to my map's shader file. Here is what I whipped up:

Glass Shader Code

   qer_editorimage models/mapobjects/urbanterror/lamp/glass.tga
   q3map_surfacelight 14000
   //same colour light as the sky
   q3map_lightImage textures/village2/VillageSkyImageLightOrange.jpg
   surfaceparm nomarks

     map $lightmap
     rgbGen identity
     map models/mapobjects/urbanterror/lamp/glass.tga
     blendFunc GL_DST_COLOR GL_ZERO
     rgbGen identity
     map models/mapobjects/urbanterror/lamp/glass.tga
     blendfunc GL_ONE GL_ONE

Abbey model lighting That worked perfectly well when I tested it. When I sent it off to bladekiller though it stuffed up the model on every map that was using it. The model's glass had all turned orange.

The way to fix that and still keep the lighting is simply to not include the shader with the maps release. The lighting will still be created in the lighting stage of compilation, but since the shader isn't included the model's colour stays the same. This means that the texture doesn't glow the colour like it normally would. It's not perfect by any means but it is flexible.

Using this method there's nothing to stop you from editing an existing light models brightness, or even going so far as to have a plant that gives off it's own light. Just remember to comment out the texture shader for the release version.

Level Image