From bd57f345ed9dbed1d81683e48199626de2ea9044 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 27 Jun 2025 10:18:39 -0700 Subject: Restructure project --- contrib/cgltf-tangents/README.md | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 contrib/cgltf-tangents/README.md (limited to 'contrib/cgltf-tangents/README.md') 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 @@ +# cgltf-tangents + +A library to compute missing tangent vectors in glTF models using MikkTSpace. + +## Example + +``` +// Load the glTF scene and buffers as usual. +cgltf_result result = cgltf_parse_file(&options, filepath, &data); +cgltf_load_buffers(&options, data, filepath); + +// Compute missing tangents. +cgltfTangentBuffer* tangent_buffers = 0; +cgltf_size num_tangent_buffers = 0; +cgltf_compute_tangents(&options, data, &tangent_buffers, &num_tangent_buffers); +``` + +## About + +This is a single-header/source library that combines +[MikkTSpace](https://github.com/mmikk/MikkTSpace) and +[cgltf](https://github.com/jkuhlmann/cgltf) to compute missing tangent vectors +for models. + +Mesh primitives in glTF may have a normal map but not necessarily tangent +vectors. An example is the +[DamagedHelmet](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/DamagedHelmet/glTF) +sample. From the +[spec](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes): + +*"When tangents are not specified, client implementations SHOULD calculate +tangents using default MikkTSpace algorithms with the specified vertex +positions, normals, and texture coordinates associated with the normal texture."* + +cgltf-tangents takes an input glTF scene and scans it for mesh primitives that +have a normal map but no tangents. cgltf-tangents then invokes MikkTSpace to +compute tangents for those mesh primitives and outputs an array of tangent +buffers. The client can then upload these buffers to GPU memory for rendering. + +See `test/` for a complete example. + +MikkTSpace is packaged here for convenience. cgltf must be obtained separately. -- cgit v1.2.3