Parallax mapping

From Valve Developer Community
Revision as of 22:56, 17 March 2006 by N-neko (talk | contribs) (link to Parallax Occlusion Shader for Half-Life 2 download)
Jump to: navigation, search
Note.png Note: The parallax mapping feature is currently disabled in Source Engine shaders so you will not notice any results, but it is very easy to implement; hardly any coding experience is needed. Many mods have already implemented it. See "Enabling Parallax mapping in the code" Also you can download user-made Parallax Occlusion Shader for Half-Life 2

A parallax map (also known as a Photonic map, Offset map or Virtual Displacement map) will cause your flat material to look 3D. Parallax maps compliment bump maps and normal maps. 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:
    "$basetexture" "walls/brickwall"
    "$surfaceprop" "brick"
    "$bumpmap" " walls/brickwall_normal"
    "$parallaxmap" "walls/brickwall_height"
    "$parallaxmapscale" 0.05

See also

Creating Materials

Creating Normal Maps

Wikipedia:Parallax mapping

External links