BVTKNodes gallery

Thank you very much @tkeskita. I want to emphasize that this is not a particle visualization using Blender physics. The flow field of the water flow as well as particles (250 balls with 1cm diameter, released every 20 sec) were calculated with an FEM based CFD solver. Simulation time on a 4 core cpu: 4 hours WCT for some hours real time of the transient flow field and about 10 minutes for 300sec particle tracing. Subsequently, flow field and particle velocity were exported to VTU and imported into Blender with BVTKNodes. The only modelling in Blender is the re-creation of the channel walls, which seamlessly adapt to the unstructured mesh.

For those of you who know VTK and Python:

BR,
Tuomo

2 Likes

Hello!

I’ve now added the “VTK To Blender Particles” node to BVTKNodes add-on. This node converts VTK point data into Blender Particle System, using a user specified Glyph object to visualize points. It is possible to specify vector array to be used for directing the glyph, and scalar arrays for scale and color ramp. This approach should be much faster (memory efficient) for rendering of particles than the previous route by generating glyph surfaces in VTK!

Here is example with 100000 particles visualized as fairly high resolution arrows. Please note the documentation and please be aware this node is very experimental! There is also a weird random(?) rendering issue (see docs) which I haven’t figured out.

1 Like

Here’s another test where arrows are scaled and colored according to absolute relative velocity.

1 Like

Hi @tkeskita,

thank you for developing the VTK to Blender Particles node. It works well for me.
However, so far I am not very familiar with Blender particles, so I was not able to manipulate with them in the scene (scaling, rotation, …). Also, is it possible to use the Color Mapper node for coloring the particles?

In the meantime, I was able to convert the VTK datasets to OpenVDB and import them into Blender. Here is a quick result:

@Kareem,

awesome! Is that volumetric OpenVDB data? How did you do the conversion? There’s generally some interest in converting VTK 3D image data into volumetric OpenVDB, see this thread. I’m actually thinking about trying to do a conversion node for VTK to OpenVDB, if I can get pyopenvdb up and running (currently Blender does not allow population of Volume Object data via Python).

Unfortunately manipulating particles in Blender seems impossible. Currently you have to do all manipulation on the VTK side. For coloring you have to use the “Generate Material” hack I set up for VTK To Blender Particles node. The material uses the “lifetime” register from Particle Info node for transferring color ramp values, which you can convert into colors with a Color Ramp in the material node tree.

BR,
Tuomo

@tkeskita,

thanks for your reply. Yes, these are volumetric OpenVDB data. I wrote a very simple C++ code that converts the vtkImageData and its vtkFloatArray to openvdb FloatGrid (I am attaching the code below). In Python, the procedure would be very similar I believe.

#include <vtkSmartPointer.h>
#include <vtkImageData.h>
#include <vtkPointData.h>
#include <vtkXMLImageDataReader.h>
#include <vtkFloatArray.h>
#include <openvdb/openvdb.h>
#include <string>
#include <iostream>

int main(int argc, char** argv) {

    if(argc < 4) {
        std::cerr << "usage: " << argv[0] << " <input> <output> <array>" << std::endl;
        return -1;
    }

    std::string input = argv[1];
    std::string output = argv[2];
    std::string array = argv[3];

    openvdb::initialize();
    openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create();
    grid->setGridClass(openvdb::GRID_LEVEL_SET);
    grid->setName(array.data());
    openvdb::FloatGrid::Accessor accessor = grid->getAccessor();
    openvdb::Coord ijk;

    auto reader = vtkSmartPointer<vtkXMLImageDataReader>::New();
    reader->SetFileName(input.data());
    reader->Update();
    vtkSmartPointer<vtkImageData> vtk_grid = reader->GetOutput();
    vtkSmartPointer<vtkFloatArray> vtk_array = vtkFloatArray::SafeDownCast(vtk_grid->GetPointData()->GetArray(array.data()));

    auto dims = vtk_grid->GetDimensions();
    int &i = ijk[0], &j = ijk[1], &k = ijk[2];
    for(k = 0; k < dims[2]; ++k) {
        for(j = 0; j < dims[1]; ++j) {
            for(i = 0; i < dims[0]; ++i) {
                accessor.setValue(ijk, vtk_array->GetTuple1(i + j*dims[0] + k*(dims[0]*dims[1])));
            }
        }
    }

    openvdb::io::File(output.data()).write({grid});

    return 0;
}
1 Like

Hi @Kareem,

I’ve been testing volumetric material, but so far results are not so nice. It seems that Principled Volume shader needs to be configured quite exactly for good results. Could you please share the material setup you used?

PS. I’m currently trying to tweak Blender external library build system to produce pyopenvdb, but it’s a mess, so gonna take some time.

Hi @tkeskita,

for each attribute I have a separate vdb file. In the image above, there are two datasets shown - the particle density and the electric field. The material setup is very simple, I am attaching it below (not exactly the same though).

I was playing around with the material settings just to get some reasonable result so far. Anyway, I think that with Blender shader editor one can get the same capabilities as, e.g., with the color map editor in ParaView, but I did not have much time to explore it yet.

1 Like

Here’s my OpenVDB tests. Here I resampled vorticity magnitude data from unstructured grid into VTK image data before exporting to .vdb. You can see the sampling artefacts. Also, there seems to be some kind of interpolation artefact when viewing grid from orthogonal angle (voxels aligned).

Anyhow, quite interesting, this volumetric rendering possibility. It would be possible make a “VTK To Blender Volume” node which exports .vdb file and imports that as a Volume Object, but currently it requires custom built libs. It will probably take some time for pyopenvdb to become available natively in Blender.

1 Like

Hi guys !

I’m needing some help on this addon :slight_smile:

I have png image slices of a volume and I’m wondering how to import them in BVTK and stack them to extract an iso-surface.

For now I’ve only managed to import and generate an outline from a single slice using the vtkPNGReader node.
I’ve seen that a vtkImageStack class exists in the VTK api, but no corresponding node in the addon :confused:

Could someone help me please ?

I also have a second question : my data are containing ID colored islands
Black = empty area
Colors = one unique color to identify each island

What would be the nodes setup (if this is possible) to extract the iso-surface from the binary mask (black vs color) and get the color assigned on the generated mesh data for each island ? (as a vertex color or uv mapped) ?

Thanks !

Hello,

I’ve been lately working on “VTK To Blender Volume” Node, which allows conversion of 3D vtkImageData into a Blender Volume Object. The node requires a custom build of Blender dependency libraries, to include pyopenvdb in Blender. Currently there’s fair chance that pyopenvdb will be part of Blender by default, but it will probably not happen very soon (maybe next year?).

I wonder are there people who would like to have instructions how to compile custom pyopenvdb-Blender on Linux, to use “VTK To Blender Volume” Node already now? Alternative is to use a custom program like that which @Kareem posted previously to generate OpenVDB file, and import that into Blender. If you would benefit from pyopenvdb-Blender custom build instructions, please like this post!

4 Likes

Learning slowly how to render volumetrics…

Edit: Added video: disc19_bvtknode_013_ani0001-0119.mkv (4.4 MB)

Edit 2: Transient data video: disc19_bvtknode_017_ani0001-0300.mkv (480.1 KB)

Hi,

the VTK To Blender Volume (OpenVDB) node is now available in BVTKNodes, but it requires custom build of Blender. Please note the documentation.

Hi,
kindly do not use this gallery thread to request support. Instead please first read the documentation. After that if you still need help, please post your question to https://github.com/tkeskita/BVtkNodes/issues , preferably attach a few small example data files and image showing your node setup in detail. Thanks!

1 Like

Hey, I’m thinking about providing an external workaround for converting VTK Image Data into OpenVDB files. Please like this post if you would benefit from such a workaround.

3 Likes

VTK To OpenVDB Exporter is now available, but conversion to OpenVDB requires access to external pyopenvdb!

Testing the VTK To OpenVDB Exporter route results:

1 Like


Playing with these nodes; gives an easy way to try different color schemes with OpenFoam results. This is simple plane-objects defined in BVTKN, in Blender i extruded planes to “sticks”, added emission to them and a volume box to add some haze… very useful tools in my opinion.

4 Likes

Hello!

I see it’s been awhile, can anybody chime in and let me know if there’s any progress on this?

I have vtk FEA stress-strain volumetric data (using FEBio and Paraview) that I desperately want to import into blender as openVDB, so that I can display and manipulate the volumetric data… basically for mesh-structure optimization.

I’m ok with compiling blender in windows using visual studio, but I’d need some basic advice as it has been a couple years. I’d rather hope there’s a way to do this in blender 2.9x…

Any info is greatly super amazingly appreciated.
Thanks

1 Like