Glowing textures (Source)

From Valve Developer Community
Revision as of 23:58, 2 December 2006 by Yar Kramer (talk | contribs) (→‎UnlitGeneric textures: Fixed a typo)
Jump to navigation Jump to search

Basics

This is a description of the steps required to achive a glowing texture. While there are a several approaches to take each will be covered here independently. Which one you wish to use is based entirely upon the situation of your use.

A glowing texture at its base is one that does not require another form of light to be lit up. It creates its own lightmap independant of all lighting sources and may even create light itself. This does not mean that the surface will appear pure white, just the face will ignore any light it would recive. This is a key difference as a glowing black stays black and does not get brighter. The face achive what is called fullbright, the texture appears exactly the same brightness as it is saved.

There are three different forms of this effect avalible in the source engine. The first is .rad files. A file parsed and run during the vrad compile process. The second is the UnlitGeneric shader, specified in certain material's VMT. The third is the $selfillum parameter, again specified in the material's vmt.

.rad files

An old method, supported mostly for legacy purposes .rad files are the only form of glowing textures that generate any light. Processed only during the compile process they are a text file found in the same directory as the .VMF file or in the root directory for the game /<e-mail>/half - life 2/hl2/<name>.rad. The file is processed line per line, on each line is simply the name of the texture, the rgb value of the light, and then the brightness of the light.

exmaple\exampletexture 128 192 96 400

When compiled there will be automatically generated lights of the specified colour and brightness infront of the world brushes face. The brightness also affects the density of the created lights, higher values will produce a more even effect. The texture itself does not become fullbright but the lights infront often make it seem so. The .rad files are the only form of glowing textures that work only upon world brushes. This is because they're processed entirely during the vrad process, something models never undergo.

When it comes to processing the file there are three names it looks for lights.rad, <game>.rad, then <mapname>.rad. Processed in that order any texture specified in any file will be given the lighting effect. If a texture is specified in multiple files it will be overridden by the latest information, for example if both lights.rad and <game>.rad specified the same texture but <game>.rad was brighter. Then the light emitted in the compiled map would be the brighter <game>.rad version.

A .rad texture inuse

UnlitGeneric textures

The UnlitGeneric shader forces the entire face to be full bright. The surface does not emit light nor does light have any visible effect on the surface. Mainly used when the texture should appear to be a light source but not wanting any light to be forced into creation. All that is required for the effect is to specify the materials shader as unlit generic.

"UnlitGeneric"
{
	"$basetexture" "example\exampletexture"
}

A common use is that of skybox textures, the sky is always bright and the face the texture will appear on has no form of lighting itself.

A unlitgeneric texture inuse

$selfillum textures

The $selfillum parameter is akin to the UnlitGneric shader. The key difference is the flexibility selfillum grants, the selfillum paramters takes the alpha channel of the base texture and turns that into a map for how bright each pixel of the image should appear. This means parital brightness or even only small areas of brightness can exsist. A partially bright face can still recive light if it out weighs the defualt light on the face. The alpha channel has to be made when creating the material but the vmt property has to exsist aswell.

"LightmappedGeneric"
{
	"$basetexture" "exmaple\exampletexture"

	"$selfillum" 1
}

This effect ends up most commonly being used when the "light" part of a texture is not the entire surfaces, such as a window on a building.

A selfillum texture inuse