Game Development Community

Normal maps

by Tom Spilman · in Torque Game Engine Advanced · 11/22/2004 (11:24 pm) · 8 replies

Ok i'm running into trouble testing out normal mapping. I've got Starter.fps converted over and working in TSE just fine. All my DIFs show up with their textures. So i decided to add a bumpmap to one of them:

datablock Material(stonewall)
{
   baseTex[0] = "starter.fps/data/interiors/stonewall";
   bumpTex[0] = "starter.fps/data/interiors/stonewall_bump";

   pixelSpecular[0] = true;
   specular[0] = "1.0 1.0 1.0 0.1";
   specularPower[0] = 32.0;
};

I opened stonewall.jpg in Photoshop and using the nVidia plugin i exported a normal map as a 32bit PNG. Now when i run TSE i get crazy flickering and what looks like z-fighting on the cottage walls where the stonewall normal mapped material is applied. I've seen this same effect at other times... is this from the initial z rendering pass? So what am i missing here to make this normal map work?

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
11/23/2004 (11:12 am)
The z-fighting happens because the interiors draw a "blank" pass on the interiors before it draws the shadered pass over it. If you don't have the interior textures mapped to materials, it will flicker because the "blank" pass uses shaders, but unmapped materials use the FFP and they don't quite match up.

Make sure your materials are mapped to all the interior textures and the flickering should all go away.
#2
11/23/2004 (11:45 am)
This is with one of the cottage interiors. When i don't have the bump map set in the material it works just fine. Remember the default materials are already mapped with a block of:

demoMaterial("MtlPilrFront","interiors");
demoMaterial("MtlPilrBottom","interiors");
demoMaterial("Mtl","interiors");
demoMaterial("F","interiors");
demoMaterial("Wall_filler1_01","interiors");
demoMaterial("Floor_tile01","interiors");
demoMaterial("FlrFiller3_01","interiors");
demoMaterial("WalMtlbase1_01","interiors");
demoMaterial("FlrFiller3_01","interiors");
// ... etc...

So i don't believe it's that the materials are not mapped. I figure there must be some screwed up double geometry in there. I'll try it with my own simple geometry.
#3
11/23/2004 (2:36 pm)
Ok it seems i solved my issues and better understand what needs to be done to map materials. In particular i was omitting the addMaterialMapping() call after creating the datablock.

Now i've generated bump maps for several of the textures from the Stronghold mission. In general they work, but the large cottage has some odd errors:

www.sickheadgames.com/stuff/cottage.png
That one black wall and that strip in the middle of the floor are pure black with bump. It's like it's not mapping the base texture to it. TSE bug, geometry bug, or my bug?

Once i get done with my experiment i'll post a zip with the material file and all the bumps for Stronghold.
#4
11/24/2004 (9:59 am)
That could be a TSE bug, it looks like the tangent space matrix might be wrong on those polys somehow. Try reducing the number of lights on the inside there and see how it affects it.
#5
11/24/2004 (10:08 am)
Got similiar stuff too with only one lighting inside our building. It also happends on the TSE demonstration building (orcbase) just outside it above the door.
#6
11/24/2004 (2:28 pm)
I removed all the lights but one and i still got the same effect. Also i noticed it only occurs on lod 0:

www.sickheadgames.com/stuff/lodcmp.jpg
So it's most definitely tied to the geometry and not the number of lights.
#7
11/24/2004 (2:38 pm)
I had the same thing, but different areas of the model.
I generated normals for all the Torque included textures and told the mapper where they were. Pretty much every model had some black streak in parts of it, although the overall effect was pretty cool.
#8
11/30/2004 (1:29 pm)
OK, noted, I'll take a look at it.