Skip to content

Commit

Permalink
update document
Browse files Browse the repository at this point in the history
  • Loading branch information
lcp29 committed Feb 15, 2024
1 parent 4517b66 commit fd1da7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Find the closest intersection for each ray.

### Returns

> ⚠️ The UV coordinates returned have different convention: `uv[0]` corresponds to the second vertex and `uv[1]` correspongs to the third vertex.
If `stream_compaction` is `False`:
- `hit` (`Bool[torch.Tensor, "*b"]`): A boolean tensor indicating if each ray intersects with the mesh.
- `front` (`Bool[torch.Tensor, "*b"]`): A boolean tensor indicating if the intersection is from the front face of the mesh.
Expand Down
13 changes: 13 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
plt.imshow(loc.cpu())
plt.show()

mesh_normals = torch.from_numpy(s.vertex_normals).cuda().float()
mesh_faces = torch.from_numpy(s.faces).cuda().int()

tri_v = mesh_faces[tri_idx]
tri_norm = mesh_normals[tri_v]
print(tri_v)
# uv[0] -> 2nd, uv[1] -> 3rd, (1 - uv[0] - uv[1]) -> 1st
hit_norm = uv[:, :1] * tri_norm[:, 1] + uv[:, 1:] * tri_norm[:, 2] + (1 - uv[:, :1] - uv[:, 1:]) * tri_norm[:, 0]
loc[hit] = hit_norm
plt.imshow(loc.cpu())
plt.show()


f = torch.Tensor(
[
[0.5, -0.5, 0],
Expand Down

0 comments on commit fd1da7a

Please sign in to comment.