cheind / pure-torch-ngp

A pure PyTorch based implementation of "Instant Neural Graphics Primitives with a Multiresolution Hash Encoding" with tweaks.
MIT License
40 stars 1 forks source link

export radiance field by grid-sampling and import in blender #2

Open cheind opened 1 year ago

cheind commented 1 year ago

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

cheind commented 1 year ago

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?

diramazioni commented 1 year ago

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!

cheind commented 1 year ago

@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)?

diramazioni commented 1 year ago

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 commented 1 year ago

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

cheind commented 1 year ago

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

diramazioni commented 1 year ago

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:

cheind commented 1 year ago

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