Seam at UV border when using normalmaps
I have an .obj model with a tangent-space normalmap, rendered using the normalmap shader that when rendered has some obvious seams in the normals near the UV borders, see http://hnsr.nl/files/prog/3js-normal-test/index2.html (Tested with Chrome 26.0.1410.19 beta and Firefox 19, on Linux with an NVIDIA GTX275 using NVIDIA driver version 313.18).
In issue #1647, someone seems to have the same problem (not the tesselation issue though, my model only has triangles), and provided some code that splits vertices along the UV seams which fixes the issue for me, see http://hnsr.nl/files/prog/3js-normal-test/index.html
I'm not exactly sure why that fix works, because from what I understand you can only have one set of indices in OpenGL that index the combined vertices properties (position, normal, other attributes) rather than being able to have them in separate arrays and indexing them seperately with multiple sets of indices, so I tried to look for a possible bug where the arrays are merged into one, but I couldn't actually find any such place in the three.js code (in fact it seems the arrays are uploaded directly to OpenGL, so maybe I'm wrong about all of this).
In any case, I'm a bit confused, but the model also renders correctly using some old C/OpenGL code or when I reimport it in blender so I figured I'd file an issue for it anyway, even though the code from the previously mentioned issue fixes it
Sorry, I am not seeing the seams you are referring to....
Also, you can try
material = new THREE.MeshPhongMaterial( { normalMap: THREE.ImageUtils.loadTexture( "asteroid_n.jpg" ) } );
This does not require you to compute tangents. See #2358.
This is what the seam looks like for me:

It's strange that you don't see it as I've reproduced it with a bunch of other machines with different browsers and OS's (though all with nvidia GPUs), not sure what's up with that.. are you sure you were looking at the index2.html one and not index.html?
I've tried the material you mentioned but I found that it didn't look as great as the shader that uses tangents, but it too has issues though and seems to require the same fix. The only difference is that with MeshPhongMaterial the discontinuities aren't just at the UV seam, but seemlingly random triangle edges.
I tried to view this but it doesn't display with a texture in Chrome stable or Firefox stable in Windows.
Huh, you're right, it all works in Firefox/Chrome on Linux, but shows up black in Firefox/Chrome under Windows, I'll see if I can fix that
~~EDIT: I must have broken something when I simplified the code for this issue, it shows up black on every Windows machine I've tried, with no errors in the console. Still working okay on Linux though (on two different Linux machines with both closed nvidia drivers or radeon/mesa)... I'm very confused.~~
Ok, having two lights broke it on Windows for whatever reason, so I reduced it to one light - should work now if you hard-refresh
Rendering your object with MeshBasicMaterial and using your normal map as the material's diffuse texture, it appears you have discontinuities in your normal map at the seams.
I can see how this is conceivably OK, as long as the creation pipeline and rendering pipeline make the same tangent space assumptions -- but I expect that is not the case.

Hmm. I must admit that I'm having a bit of diffculty wrapping my head around this as I'm not sure what the assumptions regarding tangent space I am making are. Is this due to how the model has been unwrapped or is this more about using tanget space normal maps rather than object space? Ideally I would like to simply use the right method in my content creation so I don't have to rely on extra processing in JS like I'm doing at the moment.
But I'm also a bit confused as to why the fix I am applying (http://hnsr.nl/files/prog/3js-normal-test/normalfix.js) is needed, because it doesn't seem to do anything other than ensuring vertices with different UVs aren't merged, which I thought was always required for tangent space normal maps.
Anyway, I apologize if what I say doesn't make sense, it's been a while since I've fully understood the methods and math involved and it's all a bit murky for me
I must admit that I'm having a bit of difficulty wrapping my head around this
Me, too.
Oh, I miss @alteredq...
I have spent the better part of the day on this, and I must admit, it is not easy. Computing tangent space vectors for an arbitrary mesh is not a well-defined problem, and hence, computeTangents() is a heuristic. The tangents it computes are clearly not the right ones in your case -- at least not on the seam. Adding your patch allows for two tangents at each vertex location on the seam, and this is why the rendering "looks better" in some cases.
There are people on this board who know a lot more about the creation pipeline than I do, so perhaps they will be able to chime in. In any case, the creation pipeline needs to be consistent with the rendering pipeline.
When in doubt I consult "real time rendering", a great book. It pointed me at:
http://www.terathon.com/code/tangent.html
@bhouston That is, in fact, the algorithm computeTangents() implements. :-)
It's all slowly coming back to me now, and I think that given the way the asteroid is unwrapped (and I guess there aren't many other ways to unwrap it without distortions), I'm inevitably going to end up with seams along which the TBN matrix will have a different orientation on either side, causing the discontinuities in the normalmap as shown above (but the discontinuities in the normals go away once transformed by the TBN matrix). Does that make any sense?
I don't know if this is a three.js issue, because computeTangents() clearly does the right thing after __geometry_splitByUV() splits the vertices. I'm only a bit confused about where these vertices get merged, since the .obj format simply uses multiple indices for the seperate vertex properties (f 1/1/1 2/2/2 3/3/3 etc), and the ObjLoader loads them directly into a THREE.Geometry object. Maybe they don't get shared/merged at all since that should mess up the UVs themselfes too, but then I have no idea where the problem lies (and now my head hurts)
@hnsr
Does that make any sense?
Yes, your first paragraph makes perfect sense, as long as the rendering TBN matrix is always the correct one.
I'm only a bit confused about where these vertices get merged
Bingo! You may have solved it.
OBJLoader() calls merge vertices. Comment out that line and everything looks good -- without the patch. The number of vertices is about 6 times greater, though. Actually, you only need un-merged vertices on the seams.
Ah-hah! However it seems I'm not quite there yet, if I comment out the mergeVertices() call the really obvious seam goes away, but instead I get some (more subtle) discontinuties all over the mesh: http://hnsr.nl/files/prog/3js-normal-test/nomerge.html (or see http://hnsr.nl/files/prog/3js-normal-test/almost.png) Commenting the other compute*() calls which I don't think I need didn't help either. I don't seem to get these with the __geometry_splyByUV() fix, so I'm not sure what's going on there
With you patch, there are two tangents on the seam only. When commenting out mergeVertices(), there are multiple tangents at each vertex location. In both cases, the tangents are computed via a heuristic.
What is going on, is you don't have a consistent pipeline.
Hey, i am just beginning to learn Three.js but i have some experience with 3dsMax and other software and getting your normal maps properly into an engine is not often that easy. The Problem is that different normalmap baking tools use a somewhat different tanget basis which can lead to issues. At least that is my understanding. As far as I know, Autodesk Maya and 3dsMax use different tanget basis calculations and therefore the maps baked in those programs are somewhat different. (I am not sure if they now use the same, but it doesn't matter) I am personall using xNormal quite often to bake my normal maps. Anyway check out this tool, http://handplane3d.com/, it converts object space normal maps into tanget space maps and the user can choose where it was baked and what target engine you have.
My main point is: Maybe we can find out (or ask the authors of handplane for example) what tanget basis engine X uses, lets say unity or Unreal Engine and maybe we can implement their tanget basis. This way, Three.Js would be consistent with some other big engine out there and users have tools to create proper normal maps.
@GuyGood +1
Was there ever an "out of the box" solution to the normal map seam problem? From what I gather following this issue, it sounds like the verts along seams shouldn't be merged.
I'm dealing with it right now and looking for a solution! :( (I assumed that it was okay to post here instead of StackOverflow since there was already a valid bug report here).
I tried inverting and swapping around all of the normal map channels - that didn't work.

@tranek how are you loading the model?
@mrdoob I'm using a THREE.JSONLoader to create a THREE.SkinnedMesh. The seam happens with both THREE.MeshPhongMaterial and the normal shader. I'm primarily using a modified version of the normal shader.
I see. As far as I remember, JSONLoader doesn't merge vertices.