Parallax mapping: Difference between revisions
(update) |
m (note was actually very outdated) |
||
Line 1: | Line 1: | ||
{{note| | {{note|Parallax mapping is currently disabled in the Source Engine shaders. However, it is very easy to implement with custom code; hardly any coding experience is needed. For an installable implementation, see the [http://www.hl2world.com/bbs/1-vt46068.html Extended phong and parallax shader by MihailNajdenov].}} | ||
A '''parallax map''' (also known as a '''photonic map''', '''offset map''' or '''virtual displacement map''') will make your flat material look three-dimensional. 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. | A '''parallax map''' (also known as a '''photonic map''', '''offset map''' or '''virtual displacement map''') will make your flat material look three-dimensional. 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. |
Revision as of 15:36, 18 January 2007

A parallax map (also known as a photonic map, offset map or virtual displacement map) will make your flat material look three-dimensional. 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.
Creating a height map
Regardless of the way you are going to render parallax maps, creating parallax mapped materials always starts with creating a height map.
Create a copy of your texture in grayscale. 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 filename and convert it to a VTF. Put it in the same directory as your texture.
Adding a parallax map with the built-in support for parallax maps
Add these two lines to your VMT:
"$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.
Example VMT:
"LightmappedGeneric" { "$basetexture" "walls/brickwall" "$surfaceprop" "brick" "$bumpmap" "walls/brickwall_normal" "$parallaxmap" "walls/brickwall_height" "$parallaxmapscale" 0.05 }
Adding a parallax map with the Parallax Occlusion Shader mod
First, in the VMT, add after the line
"LightmappedGeneric"
this line:
//"MN_PrlxLightmappedGeneric"
When playing a map with your parallax mapped material, comment out the first line. When compiling a map with your parallax mapped material in Hammer, comment out the last line. This (according to the author of the mod) is a workaround to a glitch in Source SDK.
Finally, add this line to your VMT:
"$heightmap" "texture name"
Other parameters you may need:
"$heightscale"
, defines the "depth" of the effect, takes values 0.0—1.0, default=0.4
"$heightmapsample"
, default=16
"$envmap"
"$envmapcontrast"
"$envmaptint"
"$NORMALMAPALPHAENVMAPMASK"
Example VMT:
//"LightmappedGeneric" "MN_PrlxLightmappedGeneric" { "$basetexture" "walls/brickwall" "$surfaceprop" "brick" "$bumpmap" "walls/brickwall_normal" "$heightmap" "walls/brickwall_height" }