Bump map: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
== Format ==
== Format ==


Each color channel in a bump map has a meaning:
Each pixel in a bump map contains the (x, y, z) coordinates that define a normalized vector. (ex. A line with a length 1 unit centered at (0,0,0) that passes through the point (x,y,z) )


# The '''red''' channel defines horizontal facing (X-axis)
Because of this each color channel in a bump map has a meaning:
 
# The '''red''' channel defines the horizontal facing (X-axis coordinate) of the vector
#:0 = left
#:0 = left
#:128 = forward (facing viewer)
#:128 = forward (facing viewer)
#:255 = right
#:255 = right
# The '''green''' channel defines vertical facing (Y-axis)
# The '''green''' channel defines the vertical facing (Y-axis coordinate) of the vector
#:0 = up
#:0 = up
#:128 = forward (facing viewer)
#:128 = forward (facing viewer)
#:255 = down
#:255 = down
# The '''blue''' channel defines height (Z-axis)
# The '''blue''' channel defines the height (Z-axis coordinate) of the vector
#:0 = deepest
#:0 = facing 'in' to the texture away from the viewer (This is a 'bad' value. Anything under 128 means that the surface should be facing away from the player. This is not possible.)
#:128 = maximum depth capable of receiving dynamic light (it's a bad idea to go under this)
#:128 = maximum depth capable of receiving dynamic light (it's a bad idea to go under this)
#:255 = at the material's surface
#:255 = facing 'out' of the texture towards the viewer


The three channels between them allow the engine to calculate a normal vector for every pixel, allowing it to generate shadows and highlights on a two-dimensional surface.
The three channels represent a normal vector for every pixel, allowing the engine to generate shadows and highlights on a two-dimensional surface. This is usually done with a simple lighting calculation such as dot( N, L ) where 'dot' is the [http://en.wikipedia.org/wiki/Dot_product dot product] equation, 'N' is the normal vector stored in the pixel, and 'L' is the lighting vector (ex. The direction the light is facing).


A bump map is largely useless for really flat surfaces like smooth concrete or metal, but even rough concrete sometimes has enough depth to it to make one worthwhile.
A bump map is largely useless for really flat surfaces like smooth concrete or metal, but even rough concrete sometimes has enough depth to it to make one worthwhile.

Revision as of 18:42, 4 July 2009

A material's albedo (left) compared to its bump map.
The above material in-game.

A bump map is an RGB image that can be used to simulate a three-dimensional surface through a process known as normal mapping. They are sometimes called normal maps.

Format

Each pixel in a bump map contains the (x, y, z) coordinates that define a normalized vector. (ex. A line with a length 1 unit centered at (0,0,0) that passes through the point (x,y,z) )

Because of this each color channel in a bump map has a meaning:

  1. The red channel defines the horizontal facing (X-axis coordinate) of the vector
    0 = left
    128 = forward (facing viewer)
    255 = right
  2. The green channel defines the vertical facing (Y-axis coordinate) of the vector
    0 = up
    128 = forward (facing viewer)
    255 = down
  3. The blue channel defines the height (Z-axis coordinate) of the vector
    0 = facing 'in' to the texture away from the viewer (This is a 'bad' value. Anything under 128 means that the surface should be facing away from the player. This is not possible.)
    128 = maximum depth capable of receiving dynamic light (it's a bad idea to go under this)
    255 = facing 'out' of the texture towards the viewer

The three channels represent a normal vector for every pixel, allowing the engine to generate shadows and highlights on a two-dimensional surface. This is usually done with a simple lighting calculation such as dot( N, L ) where 'dot' is the dot product equation, 'N' is the normal vector stored in the pixel, and 'L' is the lighting vector (ex. The direction the light is facing).

A bump map is largely useless for really flat surfaces like smooth concrete or metal, but even rough concrete sometimes has enough depth to it to make one worthwhile.

Creation

A bump map should:

  • Be at the same resolution as the albedo/s it is to be used with.
  • Be stored in an uncompressed format (see Conversion).

Programs

Bump maps as created by various programs.

Various programs can automate the creation of bump maps, either by image analysis or by using 3D geometry the user provides.

2D
Photoshop or Paint Shop Pro
The GIMP
3D
XSI
ZBrush2
Lightwave
3D Studio Max
Maya
Blender
NVIDIA Melody
Cinema 4D
NormalMapper
xNormal
Other
CrazyBump: Produces some very good normal maps. Some of them can be argued as almost having the same depth as a parallax map.
ShaderMap: A free alternative to CrazyBump.
SSBump Generator 5.0: Another free alternative to CrazyBump that generates Self Shadowed Bump Maps as well as normal maps.
Normal2dudv: a third party tool for converting bump maps to Dx8-friendly du/dv maps.

Conversion

In VTFEdit

When converting your texture:

  1. Choose BGR8888 or BGRA8888 (if your texture has an alpha channel) as your image format.
    Tip.pngTip:You can sometimes get away with DXT compression.
  2. Check the "Normal map" box in the texture's flags list after the import is complete. It's about 1/5 of the way down the list.
Tip.pngTip:VTFEdit can automatically generate bump maps. See the bottom-right of the import screen.

In Vtex

  1. Save your normal map as a TGA in the same resolution as the original texture. Give it a name that ends in _normal. The _normal at the end of the name will affect how Vtex converts it. For the brick wall example, we would name the file brickwall_normal.tga.
  2. Add nocompress 1 and normal 1 to <texture filename>.txt in the same folder as your texture, then compile.

Implementation

See $bumpmap.

See also

Template:Otherlang:en Template:Otherlang:en:jp Template:Otherlang:en:fr