a8c81ffa83
This patch makes it possible to change the precision with which to store volume data in the NanoVDB data structure (as float, half, or using variable bit quantization) via the previously unused precision field in the volume data block. It makes it possible to further reduce memory usage during rendering, at a slight cost to the visual detail of a volume. Differential Revision: https://developer.blender.org/D10023
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
/* SPDX-License-Identifier: Apache-2.0
|
|
* Copyright 2011-2022 Blender Foundation */
|
|
|
|
#ifndef __IMAGE_VDB__
|
|
#define __IMAGE_VDB__
|
|
|
|
#ifdef WITH_OPENVDB
|
|
# include <openvdb/openvdb.h>
|
|
#endif
|
|
#ifdef WITH_NANOVDB
|
|
# include <nanovdb/util/GridHandle.h>
|
|
#endif
|
|
|
|
#include "scene/image.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
class VDBImageLoader : public ImageLoader {
|
|
public:
|
|
#ifdef WITH_OPENVDB
|
|
VDBImageLoader(openvdb::GridBase::ConstPtr grid_, const string &grid_name);
|
|
#endif
|
|
VDBImageLoader(const string &grid_name);
|
|
~VDBImageLoader();
|
|
|
|
virtual bool load_metadata(const ImageDeviceFeatures &features,
|
|
ImageMetaData &metadata) override;
|
|
|
|
virtual bool load_pixels(const ImageMetaData &metadata,
|
|
void *pixels,
|
|
const size_t pixels_size,
|
|
const bool associate_alpha) override;
|
|
|
|
virtual string name() const override;
|
|
|
|
virtual bool equals(const ImageLoader &other) const override;
|
|
|
|
virtual void cleanup() override;
|
|
|
|
virtual bool is_vdb_loader() const override;
|
|
|
|
#ifdef WITH_OPENVDB
|
|
openvdb::GridBase::ConstPtr get_grid();
|
|
#endif
|
|
|
|
protected:
|
|
string grid_name;
|
|
#ifdef WITH_OPENVDB
|
|
openvdb::GridBase::ConstPtr grid;
|
|
openvdb::CoordBBox bbox;
|
|
#endif
|
|
#ifdef WITH_NANOVDB
|
|
nanovdb::GridHandle<> nanogrid;
|
|
int precision = 0;
|
|
#endif
|
|
};
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
#endif /* __IMAGE_VDB__ */
|