[Mesh2Volume] Grid values are not correct

292 views
Skip to first unread message

Yashiz Xastec

unread,
Jun 23, 2014, 12:03:53 PM6/23/14
to openvd...@googlegroups.com
Hello everyone,

I am quite new to OpenVDB and now I meet some problems, please help.

What I did:

I read the smoke.vdb file into MyVolume and visualize the grid values,
then I convert MyVolume  into a mesh, which I use to generate a new 
volume called MyVolume_new with a Mesh2Volume feature in OpenVDB.

Of course, MyVolume and MyVolume_new can not be exactly the same.
However, I found the grid values are different at all, or even reversed. I don't
know how to solve this problem.

Here is some pCode:

// for density visualization

for (iter = aVolume->tree().beginNode(); iter; ++iter)
// read value (density) from a node;
openvdb::Coord nodeCoord = iter.getCoord();
float fDensity = aVolume->tree().getValue(nodeCoord);

// draw AABB
openvdb::CoordBBox bbox = iter.getBoundingBox();
const openvdb::Vec3d min(bbox.min().x() - 0.5, bbox.min().y() - 0.5, bbox.min().z() - 0.5);
const openvdb::Vec3d max(bbox.max().x() + 0.5, bbox.max().y() + 0.5, bbox.max().z() + 0.5);

openvdb::Vec3d Vertex1 = aVolume->indexToWorld(min);
openvdb::Vec3d Vertex8 = aVolume->indexToWorld(max);
DrawCube(Vertex1,Vertex8,Color(fDensity, 0, 0));
}

// volume to mesh
openvdb::tools::VolumeToMesh mesher(
MyVolume->getGridClass() == openvdb::GRID_LEVEL_SET ? 0.0 : 0.01);
mesher(*MyVolume);

Then I store points quads and etc. following the function "MeshOp" in RenderModules.h of OpenVDB

// Mesh to volume
MyVolume_new = openvdb::tools::meshToUnsignedDistanceField<FloatGrid>(MyVolume->transform(), points, triangles, quads, 1.0);

Here is a result: left is MyVolume and right is MyVolume_new 


I think there must be a problem since when I do the ray marching, MyVolume_new  is very strange.

Here is a result of  ray marching: left is MyVolume and right is MyVolume_new( the density is almost reversed)

Thank you very much

Yashiz Xastec

unread,
Jun 24, 2014, 9:36:32 AM6/24/14
to openvd...@googlegroups.com
Here is a result in the openvdb_viewer.
The left one is MyVolume_new and the right one is MyVolume.
I don't know whether this phenomenon is normal.


OpenVDB Support

unread,
Jun 24, 2014, 12:59:35 PM6/24/14
to openvd...@googlegroups.com
Hi Yashiz,

The unsigned distance field is a quite different from the original density volume that you started with. Density volumes have a zero background value and set values are typically in the 0.0 to 1.0 range. An unsigned distance field is zero at the interface and increases monotonically away from it. The background is set to the maximum distance.

Best,
Mihai

Yashiz Xastec

unread,
Jun 25, 2014, 10:26:41 AM6/25/14
to openvd...@googlegroups.com
Thank you very much for the reply.

So, how can I generate a density volume with mesh2volume feature in the OpenVDB?
I found, there are only three choices, meshToLevelSet, meshToSignedDistanceField and meshToUnsignedDistanceField.
I would like to know how coherent it will be between MyVolume and MyVolume_new, if I use a correct conversion.



Reply all
Reply to author
Forward
0 new messages