# Normal maps - Artists or Code?

This topic is 3809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi people, When a normal map appear wrong on a model, who to blame? The artists or the code? Can anyone give me tricks to handle that? If you think it's art related, how should they be careful in 3ds max while modeling, and in which direction to setup their normal maps. If it is the code, can somebody tell me what I am doing wrong? Here is how I compute a tangent / bitangent : ( Assuming I am calculing verts[0] for the triangle verts[0..2] )
Edge1.Set(
verts[1].x - verts[0].x,
verts[1].y - verts[0].y,
verts[1].z - verts[0].z);
Edge2.Set(
verts[2].x - verts[0].x,
verts[2].y - verts[0].y,
verts[2].z - verts[0].z);
Edge1uv.Set(
verts[1].u - verts[0].u,
verts[1].v - verts[0].v);
Edge2uv.Set(
verts[2].u - verts[0].u,
verts[2].v - verts[0].v);

HGfloat cp = Edge1uv.Cross(Edge2uv);

if (cp != 0.0f)
{
HGfloat mul = 1.0f / cp;
tangent   = (Edge1 * -Edge2uv.y + Edge2 * Edge1uv.y) * mul;
bitangent = (Edge1 * -Edge2uv.x + Edge2 * Edge1uv.x) * mul;

normal.Set(verts[0].nx, verts[0].ny, verts[0].nz);

bool inverted = false;

if (normal.Dot(tangent.Cross(bitangent)) < 0) inverted = true;

if (inverted)
{
tangent = normal.Cross(bitangent).Normalize();
bitangent = tangent.Cross(normal).Normalize();
}
else
{
tangent = bitangent.Cross(normal).Normalize();
bitangent = normal.Cross(tangent).Normalize();
}
}

verts[0].tx = tangent.x;
verts[0].ty = tangent.y;
verts[0].tz = tangent.z;
verts[0].bx = bitangent.x;
verts[0].by = bitangent.y;
verts[0].bz = bitangent.z;


We will eventually rework the Max exporter to get the values 3ds max gives us, but for now I need the artists to visualize at least a correct model. Thanks a lot guys.

##### Share on other sites
Quote:
 Original post by DaivukWhen a normal map appear wrong on a model, who to blame? The artists or the code?

If one is wrong, it's art. If all are wrong, it's code. :)

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 26
• 10
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
633717
• Total Posts
3013509
×