ADD: Normal mapping

This commit is contained in:
2025-11-01 17:32:14 +09:00
parent d5ff6263ee
commit fbc937974d
28 changed files with 2802 additions and 264 deletions

20
src/scene/tangent_space.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <vector>
#include <cstddef>
#include <core/vk_types.h>
namespace geom {
// Generate per-vertex tangents with a robust fallback when MikkTSpace is not available.
// - Fills Vertex.tangent (xyz = tangent, w = handedness sign for B = sign * cross(N, T))
// - Expects valid normals and UVs; if UVs are degenerate, builds an arbitrary orthonormal basis.
void generate_tangents(std::vector<Vertex>& vertices, const std::vector<uint32_t>& indices);
// Range variant for submeshes (indices [indexStart, indexStart+indexCount), vertices [vertexStart, vertexStart+vertexCount))
void generate_tangents_range(std::vector<Vertex>& vertices, const std::vector<uint32_t>& indices,
size_t indexStart, size_t indexCount,
size_t vertexStart, size_t vertexCount);
} // namespace geom