pure-torch-ngp icon indicating copy to clipboard operation
pure-torch-ngp copied to clipboard

export radiance field by grid-sampling and import in blender

Open cheind opened this issue 3 years ago • 9 comments

cheind avatar Oct 22 '22 08:10 cheind

potententially use a https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/volume_principled.html shader

cheind avatar Oct 22 '22 08:10 cheind

we currently support rasterizing the volume and exporting the data as npz file. This can be loaded in vispy for rendering, but support is limited. See https://github.com/cheind/torch-instant-ngp/blob/5c6b035601cfd2bf2506856e4552147ec5bd4feb/scripts/vispy_render.py for a working example.

for blender it seems like we need to have openvdb support, but the python-interface seems to be quite nasty to use. Maybe consider a simple pybind11 wrapper for the API we need?

cheind avatar Oct 23 '22 06:10 cheind

Geometry nodes in Blender 3.3 have now the "Volume Cube" thanks to the author of b3dsdf that have a nice collection of useful nodes. It would be very useful to have this implemented inside blender as an addon!

diramazioni avatar Nov 09 '22 08:11 diramazioni

@diramazioni thanks for mentioning! I'm not familiar with geometry nodes: how would you link up the nodes so that it reads a discretized field composed of density/color values (from some source: file, python code)?

cheind avatar Nov 09 '22 09:11 cheind

I'm no expert either but looks like the volume cube accepts only density values (no much info about it). In any case I've researched for a way to get the data in and I found this addon that reads csv/json and import it in geometry nodes's spreadsheet.

diramazioni avatar Nov 09 '22 09:11 diramazioni

Upon researching it a bit further, writing openVDB seems the way to go and import into Volumetric Grids inside GeometryNodes. Blender and volume object using openvdb python example

diramazioni avatar Nov 09 '22 14:11 diramazioni

I've come accross vdp, but its python interface is quite broken as far as installation on windows etc. is concerned.

cheind avatar Nov 09 '22 15:11 cheind

It seems indeed complicated, and not officially supported on win. I found this bug report with instructions for win10. Also I can't seems to find pyopenvdb on pip (on linux). I've yet to attempt to build it my self for linux following the official guide. Anyway openVDB seems to be the only way to do it in Blender

Researching on this issue I've also found:

  • YT (an open-source, permissively-licensed python package for analyzing and visualizing volumetric data)

  • NanoVDB Nvidia's GPU accelerated VDB supposedly already integrated in blender. However there is little info about it. One advantage is that is implemented in few header files, and has virtually no dependencies on external libraries NanoVDB info

diramazioni avatar Nov 09 '22 17:11 diramazioni

Thanks for your research. I've come across NanoVDB previously, but haven't been able to find out whether it delivers a custom vdb writer. As an alternative I've considered to write a minimal openvdb file writer similar to what I've done for EXR

cheind avatar Nov 10 '22 05:11 cheind