Repository navigation
Conversation
|
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for tangent space computation and ambient occlusion rendering to triangle meshes. The key changes include implementing MikkTSpace for tangent space calculation, enabling normal map transformations between world and tangent space, and adding ambient occlusion texture generation using ray casting.
Key changes:
- Integration of MikkTSpace library for computing tangent space vectors
- New methods for ambient occlusion computation and normal map transformation
- Addition of quasirandom sequence generation and cross product operations for tensor math
- Wayland compatibility fixes for GLFW window positioning
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/open3d/t/geometry/TriangleMesh.cpp | Implements ComputeTangentSpace(), TransformNormalMap(), and ComputeAmbientOcclusion() methods |
| cpp/open3d/t/geometry/kernel/mikktspace.h | Adds MikkTSpace library header for tangent space computation |
| cpp/open3d/t/geometry/kernel/mikktspace.c | Adds MikkTSpace library implementation (1899 lines) |
| cpp/open3d/core/Tensor.cpp | Implements Quasirandom(), Cross(), and Norm() tensor operations |
| cpp/tests/t/geometry/TriangleMesh.cpp | Adds comprehensive tests for tangent space and ambient occlusion |
| cpp/pybind/t/geometry/trianglemesh.cpp | Exposes new mesh methods to Python bindings |
| cpp/open3d/visualization/visualizer/Visualizer.cpp | Adds Wayland platform checks for window positioning |
| cpp/open3d/t/io/file_format/FileASSIMP.cpp | Updates texture export to include ambient occlusion maps |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // bool visible = !(flags & FLAG_HIDDEN); | ||
| glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); |
There was a problem hiding this comment.
The commented-out code for handling window visibility should either be removed or replaced with a TODO comment explaining why it was disabled. Leaving dead code without explanation reduces maintainability.
| //if (!visible) { | ||
| // glfwHideWindow(glfw_window); | ||
| //} else { | ||
| // glfwShowWindow(glfw_window); | ||
| //} |
There was a problem hiding this comment.
Large block of commented-out code without explanation. If this code is no longer needed, it should be removed. If it's kept for reference, add a comment explaining why it's disabled.
| //if (!visible) { | |
| // glfwHideWindow(glfw_window); | |
| //} else { | |
| // glfwShowWindow(glfw_window); | |
| //} |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 15 comments.
Comments suppressed due to low confidence (1)
cpp/open3d/core/Tensor.cpp:1
- Broadcasting +
axishandling is inconsistent when tensors have different ranks. Example:ashape (3,) andbshape (N,3) with default axis=-1:Slice(axis,...)onaresolves to axis 0, but ondst_tensor(rank 2) resolves to axis 1, leading to incorrect slicing or runtime errors. Consider normalizingaxisrelative to the broadcasted/output ndim and mapping it consistently for both inputs (e.g., treat inputs as left-padded with 1s and adjust the axis accordingly), or move the target axis to the last dimension, compute, then move it back.
// ----------------------------------------------------------------------------
| // Visual inspection. | ||
| t::io::WriteImage("baked_tangents.png", | ||
| mesh.GetMaterial() | ||
| .GetTextureMap("tangents") | ||
| .To(core::UInt8, false, 127.5, 127.5)); | ||
| t::io::WriteImage("baked_normals.png", | ||
| mesh.GetMaterial().GetTextureMap("normals").To( | ||
| core::UInt8, false, 127.5, 127.5)); |
| t::io::WriteTriangleMesh("torus_ao.glb", mesh); | ||
| t::io::WriteImage("torus_ao_texture.png", mesh.GetMaterial().GetAOMap()); |
| // Bake positions and normals into textures. | ||
| const float margin = | ||
| (tex_width + 511.f) / 512.f; // = ceil(tex_width / 512) | ||
| auto baked_textures = | ||
| BakeVertexAttrTextures(tex_width, {"positions", "normals"}, margin, | ||
| /*fill=*/0.0, /*update_material=*/false); | ||
| Tensor position_map = | ||
| baked_textures["positions"].To(GetDevice(), core::Float32); | ||
| Tensor normal_map = | ||
| baked_textures["normals"].To(GetDevice(), core::Float32); | ||
|
|
||
| RaycastingScene rcs; | ||
| rcs.AddTriangles(*this); |
| Tensor valid_positions = positions.IndexGet({valid_indices}); | ||
| Tensor valid_normals = normals.IndexGet({valid_indices}); | ||
|
|
||
| Tensor origins = valid_positions.Expand({n_rays, n_valid_pixels, 3}); |
| // bool visible = !(flags & FLAG_HIDDEN); | ||
| glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); |
| std::string ToString() const; | ||
|
|
||
| /// Returns the texture map map | ||
| /// Returns the texture maps |
β¦nce (correct for non-orthogonal basis). Batched ray casting for AO + 1 bug fix.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 16 comments.
Comments suppressed due to low confidence (1)
cpp/open3d/t/geometry/TriangleMesh.h:1
- The new API docs are inconsistent with the implementation:
ComputeTangentSpace()only sets atangentsattribute (N,4) and does not add abitangentsvertex attribute, andTransformNormalMap()does not require a precomputedbitangentsattribute (it reconstructs B from the tangent sign andcross(N, T)). Update the docstrings to match actual requirements/outputs (e.g., document the (N,4) tangents-with-sign convention and remove thebitangentsrequirement/claim).
// ----------------------------------------------------------------------------
Switch to tbb parallel reduce, for export depth image, since AppleClang lacks execution policy.
gcc error in filament v 1.57.2
Type
Motivation and Context
Normal maps are saved in tangent space. This PR adds functions to compute the tangent space of a mesh and convert a normal map between world space and tangent space.
Ambient occlusion allows meshes to be visualized properly without any color information. It can also be used for simple de-lighting.
Checklist:
python util/check_style.py --applyto apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
This PR adds support for tangent space computation and ambient occlusion rendering to triangle meshes. The key changes include implementing MikkTSpace for tangent space calculation, enabling normal map transformations between world and tangent space, and adding ambient occlusion texture generation using ray casting.
Key changes:
Baked Tangents



Baked normals
Original World space normal map
[Computed] Tangent space normal map

[Computed] Restored world space normal map

AO for torus (64 samples, infinity hit)
