Page MenuHome

Fix T81983: openvdb trees with tiles not rendered correctly in cycles
ClosedPublic

Authored by Brecht Van Lommel (brecht) on Nov 13 2020, 5:59 PM.

Details

Summary

The algorithm used to build a mesh around the volume only considered leaf nodes.
However, an openvdb can also contain tiles to reduce memory consumption.

This case is rare when dealing with simulated volumes though, because usually
neighboring voxels don't have exactly the same values.

The fix is to bail out of this optimization when the tree has any tiles.
A more complicated algorithm could build a more tight mesh when there are
any tiles, but implementing this does not seem worth the complexity (yet).

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Nov 13 2020, 5:59 PM
Jacques Lucke (JacquesLucke) created this revision.

Thanks, but I rather not disable this optimization if the volume has even one
tile, that seems rather unpredictable.

Here is code to take into account tiles, iterating over what would have been
the leaf node bounding boxes if the leafs existed. Since visiting these bounding
boxes requires a functor, also refactor the code to move utility functions into
the same class.

intern/cycles/render/volume.cpp
310

Are copying the tree on purpose?

310

"A function defined entirely inside a class/struct/union definition, whether it's a member function or a non-member friend function, is implicitly an inline function."

https://en.cppreference.com/w/cpp/language/inline

Besides the comments above, this looks good to me. I was a bit to lazy to get into that -.-
Good to know that tree.visitActiveBBox exists.

Jacques Lucke (JacquesLucke) added inline comments.
intern/cycles/render/volume.cpp
310

This function does not seem to be used.

This revision is now accepted and ready to land.Nov 16 2020, 1:58 PM

This seems reasonable, however have you tried using Tree::voxelizeActiveTiles? Since we have a MaskGrid it will not do any memory allocation, just updating the node's active masks. Then we won't have to have a special case for tiles in the code. I just tried it and it works on the bug report file, maybe there is a special case that I am missing.

diff --git a/intern/cycles/render/volume.cpp b/intern/cycles/render/volume.cpp
index 64196cdd8a8..ac96fd1fb34 100644
--- a/intern/cycles/render/volume.cpp
+++ b/intern/cycles/render/volume.cpp
@@ -285,6 +285,8 @@ void VolumeMeshBuilder::create_mesh(vector<float3> &vertices,
   vector<int3> vertices_is;
   vector<QuadData> quads;
 
+  topology_grid->tree().voxelizeActiveTiles();
+
   generate_vertices_and_quads(vertices_is, quads);
 
   convert_object_space(vertices_is, vertices, face_overlap_avoidance);

Well, that's a lot simpler. If that fixes the issue and passes the tests then you can go ahead and commit that to 2.91. I guess it's a bit more memory in that it still creates the actual leaf nodes, but it should be negligible.

Well, that's a lot simpler. If that fixes the issue and passes the tests then you can go ahead and commit that to 2.91. I guess it's a bit more memory in that it still creates the actual leaf nodes, but it should be negligible.

Indeed, I was thinking about the actual voxel buffers. Allocating a bunch of empty leaves is still peanuts compared to that.

Anyway, the tests are passing, and AFAICT there is no side effects, so I am gonna commit this little fix.