Original Post
For my voxel terrain editor, I need to calculate tangents for all generated vertices. By using the method of taking the UV coords, it produces bad results, because this terrain is using tri-planar texturing (3 sets of UV coords, interpolated using the normal).
If I understand correctly, the tangent and bitangent vectors are perpendicular to the normal, and follow the direction of the U and V.
My UVs are ourrently generated from the position of the vertices, something like
U = vertex.y * UVScale
V = vertex.y * UVScale
W = vertex.z * UVScale
I tried using the face normals to select the two coords of the the three (eg: when the face normal is pointing to the Y direction, pick X and Z for uvs).
This doesnt produce smooth tangent vectors.
Since the UVs are dependent from the position, we can assume they're always pointing in the positive direction, and somehow calculate a perpendicular vector to the normal, to get the tangent?
If I understand correctly, the tangent and bitangent vectors are perpendicular to the normal, and follow the direction of the U and V.
My UVs are ourrently generated from the position of the vertices, something like
U = vertex.y * UVScale
V = vertex.y * UVScale
W = vertex.z * UVScale
I tried using the face normals to select the two coords of the the three (eg: when the face normal is pointing to the Y direction, pick X and Z for uvs).
This doesnt produce smooth tangent vectors.
Since the UVs are dependent from the position, we can assume they're always pointing in the positive direction, and somehow calculate a perpendicular vector to the normal, to get the tangent?