Parallax mapping

From Valve Developer Community
Jump to: navigation, search

A parallax map (also know as a displacment or height map) will cause your flat material to look 3D. When you look at a parallax mapped material at an angle, the high points will obscure the low points behind them. This is only worthwhile for textures that have depth ranging at least a few centimeters, like deep-set bricks or stone. If you're not sure about using one, then don't bother.

Adding a parallax map

1. Imagine your texture in 3D and create a new texture in grayscale where white corresponds to the pixels closest to you and black corresponds to pixels farthest from you. Save this as a TGA with _height at the end of the name and convert it to a VTF. Put it in the same directory as your texture.

2. Add these two lines to your VMF:

"$parallaxmap" "texture name"
"$parallaxmapscale" <scale value>

Fill in the path and name of your parallax map on the first line and a number between zero and one on the second line. This number affects how deep the texture will look. 0.05 is an appropriate value for bricks.

If the bricks in the example brick wall texture were really thick and stuck out from the plaster, a parallax map might be appropriate. We would create a VTF as described above named brickwall_height.vtf and place it with the other texture files. Here's an example VMT for a parallax mapped material:

"LightmappedGeneric"
{
    "$basetexture" "walls/brickwall"
    "$surfaceprop" "brick"
    "$bumpmap" " walls/brickwall_normal"
    "$parallaxmap" "walls/brickwall_height"
    "$parallaxmapscale" 0.05
}

See also

Creating Materials

Creating Normal Maps

Creating a Material Tutorial