You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a 3d numpy array containing results from a simulation which I want to render using Blender. When visualized using napari I get the expected result:
Using pyopenvdb’s copyFromArray function, I’ve attempted to import the same array within blender.
importbpy, osimportpyopenvdbasvdbimportnumpyasnp# --- Scenario 3 -> .npy import of the actual array ---actual_vol_path='/Users/tomaubier/actual_volume.npy'volume=np.load(actual_vol_path)
# numpy array to openvdb objectvecgrid=vdb.DoubleGrid()
vecgrid.name='density'vecgrid.copyFromArray(volume)
# Saving the openvdb objectvdb_file_path=f'/Users/tomaubier/openvdb_volume.vdb'vdb.write(vdb_file_path, grids=[vecgrid])
# Importing the volume within blenderbpy.ops.object.volume_import(filepath=vdb_file_path, files=[])
However this code gives me what looks like a array of shuffled values.
I then made up an arbitrary array defined as
# Making up a MWE volumex=np.linspace(0, 5*np.pi, x_shape)
y=np.linspace(0, np.pi, y_shape)
z=np.linspace(0, .2*np.pi, z_shape)
X, Y, Z=np.meshgrid(x, y, z)
mwe_volume_presave=np.cos(X*Y*Z)
and got the expected result:
To check whether or not saving and loading the values in a .npy file could be at the root of this issue, I rendered the same dummy array after saving and loading it in a numpy file. As expected this test led to the same rendered output.
I currently don’t have any clues as to whats going on.. Do you guys have any ideas?
If anyone wants to perform tests with the data I used, I've created a repo with the blender file and .npy array.
Best.
The text was updated successfully, but these errors were encountered:
Hi, I recently ran into the same problem. This might be a bit late, but I suspect there is an issue/implicit assumption with how OpenVDB copies data from Numpy arrays.
For what it's worth, what fixed it for me was making the array contiguous with np.ascontiguousarray before calling copyFromArray.
Environment
Operating System: macOS 14.1.1
Version: Blender 4.0.2
Issue
I have a 3d numpy array containing results from a simulation which I want to render using Blender. When visualized using napari I get the expected result:
Using
pyopenvdb
’scopyFromArray
function, I’ve attempted to import the same array within blender.However this code gives me what looks like a array of shuffled values.
I then made up an arbitrary array defined as
and got the expected result:
To check whether or not saving and loading the values in a
.npy
file could be at the root of this issue, I rendered the same dummy array after saving and loading it in a numpy file. As expected this test led to the same rendered output.I currently don’t have any clues as to whats going on.. Do you guys have any ideas?
If anyone wants to perform tests with the data I used, I've created a repo with the blender file and .npy array.
Best.
The text was updated successfully, but these errors were encountered: