1
$\begingroup$

I've been trying to integrate both GLTF 2.0 and blender into my asset pipeline for my custom renderer. I noticed some strange normal artifacts when normal mapping. So I go to look at my tinygltf code, low and behold for some reason the tangent vector from my blender export is a vec4 array instead of a vec3... Once I account for this, my normal mapping is fixed, and rendering looks correct.

What is going on? Is that extra value actually needed? Why does blender output vec4, and not vec3 for tangents, but vec3 for normals?

$\endgroup$
3
  • 2
    $\begingroup$ tangent.w is the bitangent sign. You use it compute the bitangent with bitangent = cross(normal, tangent.xyz) * tangent.w. See the spec. $\endgroup$
    – scurest
    Commented Apr 26, 2021 at 19:34
  • $\begingroup$ @scurest Okay, that makes sense, I thought that would be static and program defined, I guess GLTF does this for maximum compatibilities sake. $\endgroup$
    – Krupip
    Commented Apr 26, 2021 at 19:40
  • 1
    $\begingroup$ Agreed with scurest. I'll add that tangent.w is specified to only ever be 1.0 or -1.0. It's needed when the UV winding order is flipped. If you ignore it, some geometry (especially mirrored geometry) might appear with the normal map flipped inside out. $\endgroup$
    – emackey
    Commented Apr 26, 2021 at 19:47

0

You must log in to answer this question.

Browse other questions tagged .