Skip to content

Commit

Permalink
Detach vertex normals from previous AD graph on recomputation
Browse files Browse the repository at this point in the history
  • Loading branch information
dvicini authored and njroussel committed May 3, 2023
1 parent 6647d5f commit 37e0221
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/render/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ MI_VARIANT void Mesh<Float, Spectrum>::recompute_vertex_normals() {

normals = dr::normalize(normals);

// Disconnect the vertex normal buffer from any pre-existing AD
// graph. Otherwise an AD graph might be unnecessarily retained
// here, despite the following lines re-initializing the normals.
dr::disable_grad(m_vertex_normals);

UInt32 ni = dr::arange<UInt32>(m_vertex_count) * 3;
for (size_t i = 0; i < 3; ++i)
dr::scatter(m_vertex_normals,
Expand Down

0 comments on commit 37e0221

Please sign in to comment.