Check out Half-Life Re-imagined competition results!
Check out Skewing textures in Hammer, our newest tutorial!
Welcome, novandro150, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

16

Cobalt

32

Turquoise

10

Cyan

11

Royal

11

Teal

3

Onliners

3 mins

Bruce

21 mins

Strider

30 mins

Jessie

41 mins

ZikShadow

1 hours

NineTnine

1 hours

WeightlessFalls

1 hours

UrbaNebula

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

Model Transparency Tutorial

By Jakob Jungels

Note! Currently, the only way to view a model with its masked areas shown properly is to view it in the Day of Defeat 1.0 / retail mod. When other tools are available, this article will be updated.

Model transparency is a useful new addition to the Half-Life engine that will allow any model - player, weapon, or prop - to become "see through" in certain parts designated by the model's texture. This ability was normally only available with BSP polygons - world poly's. With the addition of this feature to models, an extra amount of detail can be added to any Half-Life environment without a significant loss of performance.

There are two types of transparency available in the Half-Life engine. The first form, Masked, will make certain pixels of your texture completely transparent - Masked will be the most common form since it allows you to add detail to a model without adding extra polygons. An example use of "Masked" trasnparency is with vegetation - a few polygons can now define entire branches full of leaves, while before they had to be made with world polygons.

The second form of transparency, Additive, allows you to achieve a full range of transparency. With Additive transparency certain pixels can be semi-transparent, which cannot be achieved with Masked transparency. An example use of Additive transparency is a vehicle window - a situation where you would want the glass to still remain semi-opaque.

You can achieve model transparency in two Steps.

Step 1. Prepare your model texture for transparency.

Taking your already textured model, you'll need to edit the peices that you want to be transparent. If you're using masked transparency, you'll need to fill in those areas with a solid color - I suggest using a pure color, something bright and obvious. I usually use either pure blue or pure red. Only a single color can be transparent - other colors, even if they are close to your transparent color, will not be transparent.

IMPORTANT: The color you choose to be your transparent color needs to be the LAST color listed on the color table for your final indexed .bmp. To change the last color in your color table in Adobe Photoshop, go to "Image", then "Mode", and select "Color Table." Double click the color square in the bottom-right corner (the last color), and change it to what you want to use for your transparency. Remember the RGB value of the color you've chosen.


Next, you'll need to take that color and fill in the sections of texture that you want to be transparent. I suggest using the 'pencil' tool since it does not create wet-edges. Do NOT use the paintbrush tool - the soft edges of the brush won't read as transparent in the final model.

Save your texture, making sure its the correct format - BMP, 8 bit indexed color.

Examples of a 'masked' texture before and after editing:

     

Step 2. Prepare your .qc file for transparency.

This part is easy - all you need to do is add a line to let studiomdl know what textures will use which transparency. The general format goes like this:

    $texrendermode "texturename.bmp" "<rendermode>"

So in the case of my hedgehog model which uses one transparent texture, the line in my .qc file would read as such:

    $texrendermode "hedgehog_test.bmp" "masked"

That's it for 'masked' mode. Make sure you're using a compiler (studiomdl.exe, attached below) that is compatible with model transparency.

Step 1 for additive transparency isn't as straightforward as masked. Generally, the color white will be opaque while the color black will be totally transparent. You'll need to experiment with your texture to get the right effect. No editing of the color table is required for additive transparency.

Step 2 for additive transparency is the same as masked except that the rendermode in your .qc will be "additive", not "masked". Textures that do not use transparency should not be listed in the .qc.

download