<div dir="ltr">Looking the blender code, link in enclosure, it appears that the 'tangent' is something in self.blender_mesh.loops, probably filled in other places in the glTF export code...Hmm!  But I've lost the track from there.<div><br></div><div>Apparently, I need to study the numpy python package some.</div><div><br></div><div>John<br><div><div><br></div><div>    def __get_tangents(self):<br>        """Get an array of the tangent for each loop."""<br>        self.tangents = np.empty(len(self.blender_mesh.loops) * 3, dtype=np.float32)<br>        self.blender_mesh.loops.foreach_get('tangent', self.tangents)<br>        self.tangents = self.tangents.reshape(len(self.blender_mesh.loops), 3)<br>        self.tangents = np.round(self.tangents, ROUNDING_DIGIT)</div></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jul 9, 2025 at 11:40 AM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">From Don McCurdy @ Khronos Discord:</div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br></div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div>Computed with `mesh.calc_tangents`:<br><a href="https://docs.blender.org/api/current/bpy.types.Mesh.html#bpy.types.Mesh.calc_tangents" target="_blank">https://docs.blender.org/api/current/bpy.types.Mesh.html#bpy.types.Mesh.calc_tangents</a> and then accessed here i think:<br><a href="https://github.com/KhronosGroup/glTF-Blender-IO/blob/ed5100ab6c40472b7c3254fddfe0dd0d76d60644/addons/io_scene_gltf2/blender/exp/primitive_extract.py#L1512-L1517" target="_blank">https://github.com/KhronosGroup/glTF-Blender-IO/blob/ed5100ab6c40472b7c3254fddfe0dd0d76d60644/addons/io_scene_gltf2/blender/exp/primitive_extract.py#L1512-L1517</a></div><br></div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Looks like this is export.  I’m not sure about import.</div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br></div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Anyone is welcome to have at it.  I don’t have a Tangent 3D model yet.</div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br></div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,sans-serif;font-size:19px;font-style:normal;font-weight:400;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">John</div></div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 9, 2025 at 11:16 AM Michalis Kamburelis <<a href="mailto:michalis.kambi@gmail.com" target="_blank">michalis.kambi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Indeed, taking a look at Blender -> glTF exporter should be helpful.<br>
It can already generate the 4D tangent vectors in the same format we<br>
now accept in X3D (with the W component indicating "handedness" in the<br>
same way for X3D and glTF). Note that you need to select a proper<br>
checkbox when exporting glTF to have tangents written to the file.<br>
<br>
>From my side, Tangent development:<br>
<br>
- Announced right now on<br>
<a href="https://castle-engine.io/wp/2025/07/09/support-for-new-tangent-node-in-x3d-with-vectors-as-4d-better-aligned-with-gltf/" rel="noreferrer" target="_blank">https://castle-engine.io/wp/2025/07/09/support-for-new-tangent-node-in-x3d-with-vectors-as-4d-better-aligned-with-gltf/</a><br>
<br>
- Castle Game Engine now follows the X3D Tangent spec, with MFVec4f<br>
for vectors just like for glTF. (hooray, another win for standards --<br>
glTF, X3D in X_ITE, X3D in Castle Game Engine are now all aligned.)<br>
<br>
- Our tools, like Castle Model Viewer, convert glTF to X3D, preserving<br>
tangent information from glTF into X3D Tangent node. (e.g. convert<br>
models with tangents generated by Blender or downloaded from Sketchfab<br>
or obtained from Khronos tests)<br>
<br>
- In effect we have some sample X3D files using Tangent node :<br>
<a href="https://github.com/castle-engine/demo-models/tree/master/gltf/tangents" rel="noreferrer" target="_blank">https://github.com/castle-engine/demo-models/tree/master/gltf/tangents</a><br>
. These were obtained by converting some glTFs from Sketchfab<br>
(Creative Commons licenses) -> X3D using CGE, see README there for<br>
details.<br>
<br>
- I also tested our implementation on Khronos testcase<br>
<a href="https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/NormalTangentMirrorTest" rel="noreferrer" target="_blank">https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/NormalTangentMirrorTest</a><br>
<br>
Regards,<br>
Michalis<br>
<br>
<br>
niedz., 6 lip 2025 o 07:29 John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> napisał(a):<br>
><br>
> Now….<br>
><br>
> How do we import/export a Tangent node in Blender?   Can we create a .blend file example for it so I can try exporting, then importing?  What are the Blender API data structures and methods?<br>
><br>
> I will probably look at glTF examples and intuit.<br>
><br>
> John<br>
><br>
> On Sat, Jul 5, 2025 at 8:23 AM Michalis Kamburelis <<a href="mailto:michalis.kambi@gmail.com" target="_blank">michalis.kambi@gmail.com</a>> wrote:<br>
>><br>
>> John,<br>
>><br>
>> Thank you, it's cool, every precise question helps me to explain it better :)<br>
>><br>
>> To answer that:<br>
>><br>
>> The tangent vectors (i.e., Tangent node contents) only change the way<br>
>> "final normal vector at given surface point" (designated by N in the<br>
>> lighting equations) is calculated. That's how they influence the<br>
>> calculation done by lighting equations, and thus the final rendered<br>
>> color. They do not interact with colors or geometry in any other way.<br>
>><br>
>> And the way they change this N is that tangent vectors (together with<br>
>> bitangent and per-face/per-vertex normals) define the "tangent space"<br>
>> in which the bump mapping (which is the moment where we take<br>
>> XxxMaterial.normalTexture into account) is calculated.<br>
>><br>
>> There are some resources on the web explaining this, like:<br>
>> - <a href="https://fabiensanglard.net/bumpMapping/" rel="noreferrer" target="_blank">https://fabiensanglard.net/bumpMapping/</a><br>
>> - Wikipedia: <a href="https://en.wikipedia.org/wiki/Bump_mapping" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Bump_mapping</a> ,<br>
>> <a href="https://en.wikipedia.org/wiki/Normal_mapping" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Normal_mapping</a><br>
>> - hm, ok, and much more, searching for terms like "bump mappping" or<br>
>> "normal mapping" or "bump mapping 3d opengl" yields a lot of results<br>
>> :)<br>
>><br>
>> ( One needs some disclaimer when reading them though:<br>
>><br>
>> - There are various ways to define/deal with "handedness" of the<br>
>> coordinate system. X3D spec and glTF spec match in how they handle it,<br>
>> so the world 3D coordinate space is right-handed, and the "tangent<br>
>> space" handedness is determined by the W component of 4D tangents.<br>
>> Various articles on the web don't deal with this detail, or they deal<br>
>> with it differently.<br>
>><br>
>> - The terminology distinction "bump mapping" vs "normal mapping" is<br>
>> honored/ignored differently in articles. (Admittedly, in my own<br>
>> writing sometimes too :) ) To be precise, "bump mapping" is more<br>
>> general idea, and "normal mapping" is a special case of it (when you<br>
>> do it using normal maps), and "normal mapping in tangent space" is<br>
>> even more special case of it. But...various resources simplify these<br>
>> things, because in practice "normal mapping in tangent space" is the<br>
>> most common way to do bump mapping in real-time 3D graphics (now).<br>
>> )<br>
>><br>
>> I hope any of this helps you and Don and anyone else to make sense of<br>
>> it :) Feel free to incorporate any of this in spec prose.<br>
>><br>
>> Regards,<br>
>> Michalis<br>
</blockquote></div></div>
</blockquote></div>