Map a Dream competition results on their way...
Check out Creating caves using Displacements, our newest tutorial!
Say hello to Badd, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Onliners

7 secs

potatis_invalid

25 secs

Luke

1 mins

JeffMOD

2 mins

ashephard

4 mins

Joebama

8 mins

TheGrimReafer

10 mins

Rimrook

Affliates

Some Random Site Advertisement that got here cus it's owned by an admin here.

Adding Effects to Source Textures

Page: [1] 2 3 4

Tutorials > Source > Beginner > Adding Effects to Source Textures

avatar

By the_best_flash (More from this user)
18th October, 2008
Beginner
textures, effects, souce, bump, map, env, phong, detail, decal
star star star star star (2 votes)

Adding Effects to Source Textures - Page 1

Texture Effects Tutorial

Intro

This tutorial assumes that you have a basic knowledge of the VMT file (can create a simple texture). If not I will briefly give an example below. This also assumes that you can create a VTF. I will mention some programs for creating VTF's and will also explain how to compile with them. I will first explain the differences between a basic and Decal texture. I will then explain what the bump map effect is and how to apply it to your texture, and then continue onto Env Mapping, Detail Textures, and Phong Shading model textures. I will then explain how to make specialized textures for displacement geometry. After that I will include an example map that will showcase the different texture effects. I will then finish the tutorial by discussing three tools for making VTF's and VMT's; Nem's Tools, "GIMP", and Paint.NET.

Right about now you may be wondering what VTF's and VMT's are. If you arn't skip this paragraph. A VMT or (Valve Material Type) is a text document that is used to 'program' your texture. It will take all the parts of your texture and put them together using the values you supply. They range from extremely simple to very complex. (If you want to see a complicated VMT file look at a water VMT)

------------------------------------------------------

//Comment: This is a comment and does nothing. Everything behind '//' does nothing
//A comment can be used to disable parts of a VMT without deleting all the text

"LightmappedGeneric" //The shader type (Usually is LightmappedGeneric)
{
$basetexture "MyFile/MyTextureName" //Location of VTF relative to the 'materials' folder
}
------------------------------------------------------

A VTF or (Valve Texture Format) is a picture format that is derived from TGA files. (TGA is another type of image file) So before you convert your image files to VTF you must save them as TGA files. Unlike normal pictures files, though, VTF's must have a specific size. Your VTF file does not need to be a square, but the length and width both must be a power of two (ie. 1, 2, 4, 8, 16, 32 ... 4096) they cannot exceed 4096. (SIDES MUST BE A POWER OF 2, DOES NOT NEED TO BE SQUARE)

Surface Prop

A real simple way to make any texture more interesting is the $surfaceprop modifier. This will cause the texture to behave as if it is made out of a certain material. This changes what sound the player's footsteps make, what sound collisions with the texture make, the mass of the texture, may add sound effects like echo, what sound bullets hitting the texture make, and what debris (if any) are emitted when the surface is shot.

------------------------------------------------------

"LightmappedGeneric"
{
$basetexture "YourFolder\YourTextureName" //VTF that will become the texture
$surfaceprop "brick" //will make the texture act like it's made out of brick
}
------------------------------------------------------

The default surface properties can be found here. If you are working on a mod any non-default properties can be found in the surfaceproperties_manifest.txt file located in the scripts/ folder.

Tutorial Image Example of holes in a 'metal' texture vs. holes in a 'tile' texture.

_______________________________________________

Basic and Decal Textures

Basic textures are just pictures that are used to 'paint' geometry in game, like models or walls. Decal textures could be thought of as the second layer of 'paint' on your map geometry. They are basically textures that are projected ONTO your other textures. The Valve Developer Community describes decals in this way "[They] can be used to add detail, break repetition, and create effects you cannot with standard textured surfaces alone". Some possible decals are blood, paint splatter, graffiti, road lines, and manholes. There is one type of decal texture, but two different ways to include decal textures in your map. One is the Decal Tool and the other is the Overlay Tool. I will not discuss these in this tutorial but more information can be found at the Valve Developer Community.

In order to make a decal you must first have alpha in your VTF file. To do this you would basically surround the portion of the texture you want displayed with black alpha values. Different programs have different ways of editing alpha values. In Paint.NET you would just select the parts of the texture you don't want and 'delete' them.

To make a simple decal for use in mapping you will only need these three commands:

$decal <bool> (set this to 1 for true, meaning this is a decal texture)

$decalscale <float> (This can be a decimal number it changes how big the decal will be. If set to 1; one pixel = one game unit (or inch). A 128 pixel texture with a $decalscale of 0.1 would be about a foot in game.

$translucent <bool> (Usually set to 1 for true, this allows the alpha channel to be used and allows non-square decals.)

Tutorial Image Make up of a decal texture

-------------------------------------------
"LightmappedGeneric"
{
$basetexture "decals\YourDecal" //VTF that will become the texture
$decal 1 //Makes the texture a decal
$decalscale 0.1 //Sets the scale of the decal ( '1' means 1 pixel = 1 inch. In this case 10px = 1in)
$translucent 1 //Causes the alpha channel to be used as transparency
}
------------------------------------------------------

There are other commands, but those are only used for creating decals that fade after time. These are used for blood on models or bullet holes that appear when you shoot something. I will not discuss these here as they are not useful for mapping.

Another type of decal can be used to mimic dents or pock marks. Instead of 'painting' over your texture this will lighten and darken the texture. This type of decal also requires a specially edited VTF. Your VTF will need to be a grayscale image. Every pixel over mid-range gray (RGB 128,128,128) will make the underlying texture lighter while every pixel under mid-range gray will darken the underlying texture. The alpha channel is used to control which parts of the decal will affect the underlying texture. If the alpha channel is left unedited "bordering" can occur around the edges of the decal, creating a well defined square. The VMT for this type of decal is the same as above except the "DecalModulate" shader is used instead of the "LightmappedGeneric" shader, and the $translucent and $decal values are not used.

Tutorial Image Another Type Of Decal

-------------------------------------------
"DecalModulate" //This shader is used instead of the 'LightmappedGeneric'
{
$basetexture "decals\YourDecal" //VTF that will become the texture
$decalscale 0.1 //Sets the scale of the decal ( '1' means 1 pixel = 1 inch. In this case 10px = 1in)
}

------------------------------------------------------

Bump Map

Bump Mapping or Normal Mapping is a texture effect used to cause 2-D surfaces to appear to be 3-D. It does this by allowing the Source engine to generate specialized shadows and highlights that simulate a surface that isn't flat such as a brick wall or a sandy beach. Bump maps can also be applied to models to add more detail like a woven basket, or a knotted wood desk.

Tutorial Image Bump Map on a model

Bump mapping is not done in an entirely new VMT like the decal texture; it is included in the VMT of the affected texture. A bump map requires a specially formatted VTF file that is difficult to create without specialized tools. The red, green, and blue channels of the Bump Map image effect how the image looks. I won't go into this, but the information can be found here.

First you will have to create the bump map from your texture. It is possible to create one manually, but it is extremely difficult. However, there are several free tools for creating normal maps. For Photoshop or Paint Shop pro (the tool works for both) go here. For GIMP go here. For Paint.NET go here. Or you can use other programs to generate the Bump Maps such as Nem's Tools, XSI, Blender, NVIDIA Melody, Cinema 4d, xNormal.

The tools above will take a VTF file and generate a bump map for the texture. Normally bump maps are saved with the name "BaseTextureName_normal&". So, if I had a texture named "brickWall01" I would create a bump map named "BrickWall01_normal" this is just to avoid confusion.

When using the tools you may have to change a few settings to get the effect you want. Just remember two things: The bump map will be reverse what your texture will look like (the indented parts will appear raised on your texture), and too high of a raised section will cause part of your texture to not receive any light making it constantly black.

Tutorial Image An example bump map generated from image on left

Tutorial Image Above Texture in a Game

Now that you have created the VTF the hardest part is over. Including a bump map in a texture file is as simple as adding $bumpmap "texture path" to the VMT file:

-------------------------------------------
"LightmappedGeneric"
{
$basetexture "YourFolder\YourTextureName" //VTF that will become the texture
$bumpmap "YourFolder\YourBumpMapName" //VTF that will become bump map
}
-------------------------------------------

There are other commands but they are generally not used and are more advanced. The simplest one is $bumpscale <float> (accepts a decimal or non-decimal number that will change the size of the bump map texture). Look here for more info.

_______________________________________________

Env Map

This is probably one of the more advanced texture effects. This will make a texture or model appear to be reflective or just help tint the model/texture to better match the room. This also doesn't require a new VMT, just a VTF and several variables.

Unlike bump maps the VTF files used for Environment Mapping (env mapping) are simple to create. Just create a grayscale image and increase or decrease the brightness until the desired effect is achieved. Darker areas are more reflective and lighter areas are less reflective. However, if you are using a bump map you will need to take your end result and put it into the alpha channel of the bump map VTF using an image editing program. I suggest the free image editor GIMP or the non-free Paint Shop Pro.

After you have your VTF the more difficult part begins. There are several variables you need to use. And $envmap (this will almost always be set to"env_cubemap" any other values are too advanced for this tutorial)

$envmapcontrast <normal> (This changes how bright certain colors are. 0 is normal while 1 is the color squared. To set the values use a number between 0 and 1.)

$envmapsaturation <normal> (Changes whether color is used in the cube map. 0 means it will be grayscale and 1 will be normal. Values between 0 and 1 will scale beween grayscale and full-color)

$envmapmask <texture> The VTF you created above, unless you are using a bump map. Generally these environment mask textures are named by adding "_ref" to the end of the base texture name. (ex. The env mask for "Tile01" would be "Tile01_ref") If you are using a bump map put the VTF in the alpha channel of the bump map and use $normalmapalphaenvmapmask <bool> (set it to 1 and don't set a $envmapmask).

$envmaptint (It looks like this "[0,0,0]" the first is Red, second is Green, third is Blue. "[R,G,B]". Tints the reflection with the specified color. Default is [1,1,1])

-------------------------------------------
"LightmappedGeneric"
{
$basetexture "YourFolder\YourTextureName" //VTF that will become the texture
$envmap env_cubemap //Leave this way
$envmapcontrast 0 //changes the contrast
$envmapsaturation 1 //This will cause the reflection to be full color
$envmapmask "YourFolder\YourTextureName_env"
//Use "$normalmapalphaenvmapmask 1" instead of above if using a bump map
$envmaptint "[1,1,1]" //Normal tint

}
-------------------------------------------

When your first include these textures in your map, they will not be env mapped. You will have to place env_cubemap entities in your map when you create it in Hammer. Then, after your map has been compiled, you will need to type the command 'buildcubemaps' into the developer console. After this the screen will go black and you will see a bunch of pictures flash across your screen as your cube maps are rendered. After this the map will automatically restart, and your textures will be env mapped. (Note: you will need to do this before you give out your map or else everyone you give your map to will have to run the 'buildcubemaps' command. It's better to run it once and give out your cube maped version of the map. )

-------------------------------------------
"LightmappedGeneric"
{
"$basetexture" "CustomText/GC Textures/Tile/Tile_Medium01"
"$surfaceprop" "tile"
"$bumpmap" "CustomText/GC Textures/Tile/Tile_Medium01_normal"
"$envmap" "env_cubemap"
"$envmaptint" "[ .56 .56 .56 ]"
"$envmapcontrast" 1
"$envmapsaturation" 1
"$normalmapalphaenvmapmask" 1 //Because I have a bump map
}
-------------------------------------------

Tutorial Image <- Before 'buildcubemaps' (No Env_Map) | After 'buildcubemaps' (With Env_Map) ->

Tutorial Image <- Before 'buildcubemaps' (No Env_Map) | After 'buildcubemaps' (With Env_Map) ->

_______________________________________________

Detail

Detail textures simply add detail to textures. The detail texture is a grayscale image that is used to darken a texture when the player looks at it from a short distance. This causes the texture to appear to have fine details.

Tutorial Image Example of Detail Texture from Half-Life 2 Episode 2

To create a detail texture make a grayscale .vtf file that is somewhat repeatable. It does not need to repeat perfectly because they player will only see it if they are very close to your texture, and they will usually not see more than one tile at a time. Any small seams will be mostly hidden by your main texture.

$detail FileName\TextureName

This is the location of the detail vtf inside the 'materials' folder. The $detail command has six modifying commands I will only discuss the three simpler ones. $detailscale, $detailblendfactor, and $detailblendmode .
$detailscale is the number of times your detail texture will be repeated for every one time your main texture is repeated. So if it was set to the default of 4 your detail texture would be repeated 4 times in your main texture square. This accepts floating-point numbers which means that it accepts decimals like 4.7 or 3.3 but it also accepts 4 or 3. According to the Valve Developer Community 7 or 8 is a good number for a 128 pixel detail texture.
$detailblendfactor is a number between 0 and 1 that affects how much your detail texture darkens your main texture. A value of .1 would mean that your detail texture would be almost invisible, while .98 would be almost full visibility. This value will change depending on the detail texture and main texture you are working with. I suggest looking at a few of the default VALVe detail textures below and starting with those numbers before using trial and error to find the one that works best for you.
$detailblendmode is either the number 1 or 0 with 0 being the default. All the Valve developer community says about this is to set it to 1 to darken the texture more. However, when I was experimenting with it, looked like a value of 1 would apply the detail image to the normal map of the texture (Make it bumpy) while 0 would apply the detail image to the visual texture (make it darker). I don't have any examples with this set to 1 because the extra bumpiness make all my textures look worse. Experiment with it on your own.
Here are some of VALVe's default detail textures (Note: you will not have the detail vmt files unless you have an Orange Box game)

$detail detail\plaster_detail_01 //<-- Need OB game for file
$detailscale 6.783
$detailblendfactor .8
$detailblendmode 0

Continued on next page...

Comments

avatar the_best_flash says: 8th October 2008, 05:51 AM
The tutorial is not finished... I need more pages or I need to make a 'Part 2'.

I have an example map, however it isn't ready to upload yet. I should have it finished when the rest of the tutorial is ready. What is the maximum size for example map uploads?

Thanks.
avatar Daubster says: 8th October 2008, 16:30 PM
Your pages are fairly short; Just merge some.

And I don't think upload size is limited for tutorials.
avatar the_best_flash says: 10th October 2008, 23:49 PM
Alright. Thanks.
avatar Captain P says: 14th October 2008, 11:22 AM
You may want to give a short overview of what .vmt and .vtf files are in your intro. Although it becomes apparent throughout the tutorial, I think it's a good idea to get things straight right from the start. It shouldn't take many sentences to explain anyway (something like ".vtf files contain actual images, while .vmt files control how these images are used and displayed" or such).

Linking to the various paragraphs from within the table of content would be nice, too (does TWHL provide such functionality right out of the box or do we have to resort to manually writing html?).

All in all, the tutorial comes over as trying to tell a bit about everything, so in some respects it feels cluttered (jumping from decals to dismap textures to phong shading to tools), but on the other hand, I think it's specific enough and contains a lot of information, so I think that's fine. But perhaps it's better to split things up into separate articles and link them together (one mapping-texture related, one modelling-oriented, one tool-oriented - so not part 1, part 2, but more specific titles)?

Those are my suggestions and thoughts so far. Looks good.
avatar the_best_flash says: 15th October 2008, 14:35 PM
I see what you are saying. I'll include an explanation of the vmt and vtf files as soon as I am able to edit the tutorial again. (I can't edit it because it is still waiting to be reviewed)

I would link to the paragraphs from the table of contents, however I saw no tools for that in twhl. Also I am not sure if the site will allow straight HTML. If it does I could easily add some.

And finally I think that breaking up the tutorial is a good idea, however I would have to get approval for Texture editing tutorial. (I wouldn't create a model-oriented tutorial because I only discuss one 'model only' texture effect.)

Thanks for the suggestions.
avatar the_best_flash says: 16th October 2008, 06:46 AM
I tried using some HTML, filter blocked it...

I would like to link my Table of Contents to each subject, however I don't know how.

Other than that, I believe that this tutorial is finished.
avatar Lex4art says: star star star star star 28th January 2009, 13:08 PM
Serios and large work, my respect ^_^.
avatar Daubster says: star star star star star 3rd July 2009, 10:57 AM
Indeed, great stuff.
You must be logged in to comment.