Problem with road and normalmap

Started by
1 comment, last by QNAN 11 years, 10 months ago
I have been working on roads based on splines, when I encountered a problem, where the normalmap messed up the result, based on the orientation of the road.

When I run a straight road from south to north, it looks quite normal, but when I run the same road from north to south, the road looks as if it has alot of specular value on its material, although that is not the case.
All variables are the same otherwise, like the sun (there is only one lightsource in the scene, the directional light of the sun).

It looks like this:

road_normalmap_woes.jpg


Normally when you put an object in the scene, it will come with a world matrix, through which the light direction will be transformed. That does not happen with my road, and my guess is, that that is the problem. With a winding road, there can be no single matrix for the entire road anyway. So my guess is, that this has to be solved through the calculated tangents, but I don't know if that is true, or how to do it.

Thanks in advance.
Advertisement
That's correct. Most normalmaps represent normals in tangentspace, not in worldspace or objectspace.

For the road, you have already calculated either the tangent or bitangent - that's the extrusion vector from one side of the road to the other.
The other of the 2 is more or less the cross product of that + the up vector.
It turned out that I was using a normalmap, that behaved like that. I finally tested (after excluding everything else, including my entire shader code, argh!) another normalmap, which did not have this problem.
I apologize for the trouble.

Thanks for the reply, Digital, it helped me on my way, by excluding that I had made errors in my tangent calculations.

This topic is closed to new replies.

Advertisement