Help with bump maps.

First you need to add a entry and give it a name (any name - in this example it will be ‘my_normal_map’). It’s usually added at the top of the file:

<Texture> my_normal_map  {
}

You need to point where the texture (image) file is located. It’s best to use relative paths (relative to the egg file that is). The quotes are probably not needed if you don’t have spaces in the filename - but better safe then sorry. In this example I presume the texture file is named “normal_map42.png” and it’s in a dir named “Textures” that’s one level up in the directory tree then the model file (so if the full windows-style path to the model was C:\my_game\Data\Model\my_model.egg, then the texture would be in C:\my_game\Data\Textures\normal_map42.png):

<Texture> my_normal_map  {
 "../Textures/normal_map42.png"
}

Next you need to tell panda that the texture is a normal map and should be used as such:

<Texture> my_normal_map  {
 "../Textures/normal_map42.png"
<Scalar> envtype { normal }
}

Some extra options can be added so the texture is displayed as you want it to:

<Texture> my_normal_map  {
 "../Textures/normal_map42.png"
<Scalar> envtype { normal }
<Scalar> format { rgb }
<Scalar> wrapu { clamp }
<Scalar> wrapv { clamp }
<Scalar> minfilter { linear_mipmap_linear }
<Scalar> magfilter { linear }
}

Now you need to tell panda to actually use the texture. This may take a bit more time unless you use some batch find&replace shortcuts.

For each polygon (that you want the texture to be used) you need to add a reference to the normal map texture. So if your polygons look like this:

<Polygon> {
    <VertexRef> { 23 17 14 <Ref> { Box01.verts } }
}

You need to change them to look like this:

<Polygon> {
    <TRef> { my_normal_map }
    <VertexRef> { 23 17 14 <Ref> { Box01.verts } }
}

The polygons may also have additional textures referenced or colors, don’t delete them (unless you want to):

<Polygon> {
    <RGBA> { 1 1 1 1 }
    <TRef> { Tex1 }    
    <TRef> { some_other_tex } 
    <VertexRef> { 15 4 1 <Ref> { Box01.verts } }
  }

In practice you need to find " {" and replace it with something like " {\n { my_normal_map }". The newline (\n) is optional and the file should work even if it’s all in one line.

If at this point your model has no tangent and binormals, run “egg-trans -tbnall input.egg >output.egg”. If that fails (it shouldn’t!) you can change your shader so that it won’t need tangent and binormals: Normal mapping without tangent/binormal