Difference between revisions of "Bump map"

From Valve Developer Community
Jump to: navigation, search
m (Getting the Normal Map in the Game)
(GIMP)
Line 21: Line 21:
 
===GIMP===
 
===GIMP===
  
[[Image:gimp_normal1.jpg|thumb|220px|Place the windows in a useful way]]Download the tool for GIMP [http://nifelheim.dyndns.org/%7ecocidius/normalmap/ here] and install it following the instructions in the readme.
+
[[Image:gimp_normal1.jpg|thumb|220px|Place the windows in a useful way]]Download the tool for GIMP [http://nifelheim.dyndns.org/%7ecocidius/normalmap/ here] (link broken does anyone know a mirror) and install it following the instructions in the readme.
 
After restarting GIMP, open a copy of the texture you want to create a normal map for and click:
 
After restarting GIMP, open a copy of the texture you want to create a normal map for and click:
  

Revision as of 00:15, 12 June 2006

If your texture is supposed to have depth to it, adding a normal map (successor of the bump map) will make the lighting on it far more realistic (This is perhaps the main reason Doom3, FarCry, and HL2 are able to look so much better than previous games). While bump maps only used one channel to decode the height of each pixel, normal maps use all three:

  • The blue channel decodes the height of the pixel (Z-axis)
  • The red channel contains the horizontal slope (X-axis)
  • The green channel includes the vertical slope (Y-axis)

With these 3 channels, every pixel has a normal vector, means the engine knows in which direction the pixel is facing and can thereby calculate shadows and highlights.

A normal map is kind of useless for really flat surfaces like smooth concrete or metal. But even rough concrete sometimes has enough depth to it to make a normal map worthwhile. This is an old article but explains the concept well: Normal Maps

The normal map should be created in the same dimensions as the image texture (color map) it will go with. There are a few options for how to create one, depending on the quality you want, your skill with various programs, or your patience.

Normal Map from an image editing program

Photoshop or PaintShop Pro

If you have Photoshop or PaintShop Pro, you can use NVIDIA's normal map tools, available here. To use them, open a copy of the texture and apply the Normal Map filter. Fiddle with the settings until you get something that you feel will be bumpy enough for your texture. The greater the range of colors, the greater the range of angles on the surface. A very flat surface will look that medium blue color all over. If you want to have more control over it, change the image to grayscale and fiddle with brightness and contrast to make certain details stand out before applying the filter. Be sure to change the texture back to RGB mode, or else the normal map tool will not work. Do this step multiple times to get different details to stand out, and then put the images together in layers with the blend mode set to overlay.

Image texture (color map).
Normal map created from texture on left using NVIDIA's filter.

GIMP

Place the windows in a useful way
Download the tool for GIMP here (link broken does anyone know a mirror) and install it following the instructions in the readme.

After restarting GIMP, open a copy of the texture you want to create a normal map for and click:

Filters -> Map -> Normalmap...

Before starting, you should click the 3D Preview and place it next to the normalmap window. It will automatically update when you change your settings and will be a great help checking the results in GIMP. Select a shape similar to what your texture will be placed on ingame (e.g. a texture for brushes fits onto a cube whereas a modelskin might look better on a sphere). Make use of the UV scale to find a good setting. Now focus on the Normalmap window again. These are the most useful settings:

The 3D Preview is used to check the settings
  • Filter - different ways to calculate your normal map. You'll have to try out which one works best for your texture
  • Minimum Z - the lowest height on your normal map
  • Scale - Use this to control the height of your surface. Results change when you choose a different filter
  • Conversion - Let's you choose what is used to create the normal map. Max/Min RGB or only one color channel can be very helpful sometimes

Checkboxes:

  • Wrap - Normal map will pattern seamless. Definitely use it for map textures!
  • Invert X/Y - If your normal map seems to be upside down, this will help

Check the 3D Preview from several angles, also move the light around. When you've found the best setting, hit OK and your texture is converted to the normal map! You can either go with that right away or rework it by hand. For example, you could duplicate the layer and use some overlay effects (Dodge, Addition, ...) or paint on the texture yourself if you want to create a flat part (RGB #7f7fff is flat).

Normal map was reworked by hand.

Normal Map from a Height Map

Normal Map from a 3D program

XSI

  • ver 5.0: Ultimapper
  • ver 4.x: GPU Surface FX2
    Note:You need XSI foundation or higher to take advantage of this feature, as the Mod Tool has a resolution limit.
  • ver 3.5: GPU surface FX

The name has been changing, but the basic usage is the same:

  • Move the high resolution model over the low resolution model.
  • Select the low resolution one.
  • Select GPU Surface FX2 (or Ultimapper in ver 5.0) from Get>Property.
  • In GPU Surface FX2 menu:
    • Pick the high resolution model (or group).
    • Make sure normal is checked.
    • Change settings such as normal map resolution, path, sampling, as you want.
    • If you are ready, click Regenerate button. XSI will make the normal map.
    • To preview the result, set Preview Display and Hardware correctly and click Create Preview.
    • Important: It is necessary to invert the green channel of the output file. If you don't do this, your up/down normals will appear inverted in the engine. The simplest way to do this in Photoshop is to open a channel window, (window:channel) select the green channel (which controls up/down), and press Ctrl+I.

ZBrush2

Getting the Normal Map in the Game

  1. Save your normal map as a TGA in the same resolution as the original texture. Give it a name that ends in _normal. Then convert it to a VTF. 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. Place the new VTF in the same place as your original texture.
  2. Add this line to the VMT somewhere between the braces:
    "$bumpmap" "texture name"

    and fill in the path and name of your normal map VTF. Here's an example VMT for a normal-mapped material:

    "LightmappedGeneric"
    {
        "$basetexture" "walls/brickwall"
        "$surfaceprop" "brick"
        "$bumpmap" "walls/brickwall_normal"
    }
    Note:Multiple materials can use the same normal map file.
  3. When compiling your maps with vtex, Add this line to the <texture filename>.txt file in the same directory as your textures then compile with vtex.
    "nocompress" "1"
    "normal" "1"

See also

Creating Materials

Height2Normal

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