I am doing some procedural terrain. The output of the algorithm (Dual Contouring) is a vertex list(position, normal), and a list of indices.
The output is also in Quads not triangles. I know I will have to triangulate these quads, but how do I create the tangent vectors? This terrain is smooth and the quads share verts (so I cannot create the tangents like the wiki does) it will just end up with a normal that favors the last triangle that uses that vert).
Do I create the tangents for every triangle that uses that vert then average them? It just feels like if I already have the normal I shouldn’t have to go through all that (I could be wrong, it would not be the first time).
I just spent a day forum crawling trying to figure out why the tangents I was generating were causing weirdness with bump maps on materials. What I finally discovered is that the tangents need to be pointing in the same direction as the x direction on your UV coordinates.
Hopefully, the following code snippet is enough to help out anyone who is running into the same problem later on.