AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.62k stars 647 forks source link

Draft PR: Half Grid Support for OpenVDB #1730

Open apradhana opened 9 months ago

apradhana commented 9 months ago

A draft PR on supporting Half Grid in OpenVDB. The tools we are targeting are:

A few timings from VDB Render: Case Active Voxel Count Timing Float (s) Timing Half (s)
Bunny Fog Small 19,210,271 2.7 1.15
Bunny Fog Big 176,493,009 4.83 2.47
Bunny SDF Small 5,513,993 0.0818 0.0863
Crawler 181,196,266 0.542 0.341
apradhana commented 9 months ago

Hi Dan. Thanks for looking at this PR and for all your comments. I'm trying to answer your questions here:

Can half-grid types be level sets or just fog volumes? Yes, I think level sets can also be half-grid types.

Thanks for pointing out how to do the HalfGrid registration on the RealGridTypes. I pushed an update on the PR that does the registration this way, but I'm leaving some money on the table. I did not test how grid.apply would work with RealGridTypes as you pointed out. Based on our conversation with Ken and Jeff, there can be cases where we want to do arithmetic using float when modifying a HalfGrid. So I need to double-check that there is a way for grid.apply to work when we 'specialize' an operator for HalfGrid type to use a promoted type. Do you agree with this?

Still TODO for me:

portsmouth commented 7 months ago

Great to see this PR in progress! This is functionality that is essential for Arnold renderer, to reduce the peak memory usage of scenes with large volumes.

Just to note, we also need the facility to load from full-float grids on disk into half-float grids in memory, without needing to construct an intermediary float grid and convert to half. This needs to work when demand-loading also, i.e. have a full-float grid on disk be loaded/queried incrementally as a half-float grid in memory, on a per leaf-buffer basis as values are accessed. Is that something that is easy to add on top of this PR?