aboutsummaryrefslogtreecommitdiff
path: root/contrib/cgltf-tangents/README.md
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
committer3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
commitbd57f345ed9dbed1d81683e48199626de2ea9044 (patch)
tree4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /contrib/cgltf-tangents/README.md
parent9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff)
Restructure projectHEADmain
Diffstat (limited to 'contrib/cgltf-tangents/README.md')
-rw-r--r--contrib/cgltf-tangents/README.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/contrib/cgltf-tangents/README.md b/contrib/cgltf-tangents/README.md
new file mode 100644
index 0000000..2a68b27
--- /dev/null
+++ b/contrib/cgltf-tangents/README.md
@@ -0,0 +1,42 @@
1# cgltf-tangents
2
3A library to compute missing tangent vectors in glTF models using MikkTSpace.
4
5## Example
6
7```
8// Load the glTF scene and buffers as usual.
9cgltf_result result = cgltf_parse_file(&options, filepath, &data);
10cgltf_load_buffers(&options, data, filepath);
11
12// Compute missing tangents.
13cgltfTangentBuffer* tangent_buffers = 0;
14cgltf_size num_tangent_buffers = 0;
15cgltf_compute_tangents(&options, data, &tangent_buffers, &num_tangent_buffers);
16```
17
18## About
19
20This is a single-header/source library that combines
21[MikkTSpace](https://github.com/mmikk/MikkTSpace) and
22[cgltf](https://github.com/jkuhlmann/cgltf) to compute missing tangent vectors
23for models.
24
25Mesh primitives in glTF may have a normal map but not necessarily tangent
26vectors. An example is the
27[DamagedHelmet](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet/glTF)
28sample. From the
29[spec](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes):
30
31*"When tangents are not specified, client implementations SHOULD calculate
32tangents using default MikkTSpace algorithms with the specified vertex
33positions, normals, and texture coordinates associated with the normal texture."*
34
35cgltf-tangents takes an input glTF scene and scans it for mesh primitives that
36have a normal map but no tangents. cgltf-tangents then invokes MikkTSpace to
37compute tangents for those mesh primitives and outputs an array of tangent
38buffers. The client can then upload these buffers to GPU memory for rendering.
39
40See `test/` for a complete example.
41
42MikkTSpace is packaged here for convenience. cgltf must be obtained separately.