Half-Life Zone Half-Life Zone
How to Create Realistic Looking Shadows

How to Create Realistic Looking Shadows

One of the limitations of the Gold Source engine is its weakness with shadows. Without making your own renderer (which is complex and can result in high hardware requirements) good looking shadows are very hard to achieve. Even harder still is casting shadows from models. Half-Life originally had a shadow system for models, but it was buggy and didn't look good. Using this method I discovered recently, you can create very realistic looking shadows for world geometry and models. The main downside to this is that it can only create static shadows, I've tried a few different methods but can't seem to get decals to work on moving brushes. If anyone is able to do this, please do tell me.

The way it's done is by using decals. Decals are the things that stick to the walls and floors of a map, like blood and explosion scorch marks.

How it's done

It's easy to create shadow decals. First of all you need a screenshot of the thing you want to make a shadow for or the original texture. For the grate I simply located the texture in halflife.wad using Wally. To make things easier make sure that the image you're going to create the shadow from is against a plain background (if you're doing this for a model, take the screen shot inside Half-Life Model Viewer). In the next few steps I'm using Photoshop, though I'm sure it can be done in other, free, photo editors like GIMP and Paint.net.

  • Load the image into Photoshop.
  • Go to Select>Colour Range...
  • Click on the colour you don't want to be part of the shadow (as in, the parts you want invisible)
  • Click OK and you should find all of the background is selected now.
  • Use the brush tool to paint the area white (255 255 255).
  • Press Ctrl +Shift + I to invert the selection
  • Now paint the selection grey. What shade depends on how intense you want the shadow to be. 128 128 128 usually works best. Don't use any colours; we can set the colour of the decal later on.
  • Apply a gaussian blur (Filters>Blur>Gaussian blur) to the image. How much blurring depends on how soft you want the shadow to be. In real life the closer an object is to a surface, the sharper the shadow is (try it out on a sunny day or in front of a lamp). Apply this rule to the blurring.
  • It is very likely the image will need resizing. This is one of the limitations of this method. You cannot change the size or orientation of the decal in Hammer/in game (the brush's texture scale and rotation also affects the decal. A texture scaled down to 0.5x0.5 will result in the decal being half size.)
  • Now you have your finished decal, copy and paste it into Wally. You need to save it inside the decals.wad file, otherwise it won't show up in-game. It's a good idea to use a naming scheme for these, for example {sh_xxxxx (remember to always put { before the texture name)
  • We need to change the decals palette because the one Wally has given it will not work. Find another decal with a palette that looks like this:

Greyscale colour palette

  • Now, with that decal open, go to Colors>Save Palette and save the .act file somewhere. Now go back to your shadow decal and load that palette by going to Colours>Load Palette.
  • Currently your decal will cast a grey/black shadow. If you want a coloured shadow go to Colors>Edit Palette and double click on the last colour in the grid (bottom right). Change to a colour of your choice. Avoid using bright colours as these won't look realistic.
  • You're done! Save it all and open Hammer Editor. Use the Apply Decals tool to place your decal whereever you want. Compile the map and admire your handywork!

Possible Problems

  • If Half-Life was open during all of this, restart it.
  • Make sure your decal is using the right palette. It should look like the one above.
  • Make sure you saved it inside decals.wad (you can find this inside the valve folder.

ToDo

I'm 95% sure this can be done in The GIMP so at some point I must get round to trying it out. Watch this space!

View the forum thread here

Our friends