diff --git a/intern/cycles/scene/image_vdb.cpp b/intern/cycles/scene/image_vdb.cpp index 9a205be9f38..653ed441610 100644 --- a/intern/cycles/scene/image_vdb.cpp +++ b/intern/cycles/scene/image_vdb.cpp @@ -64,7 +64,7 @@ bool VDBImageLoader::load_metadata(const ImageDeviceFeatures &features, ImageMet bbox = grid->evalActiveVoxelBoundingBox(); if (bbox.empty()) { metadata.type = IMAGE_DATA_TYPE_NANOVDB_EMPTY; - metadata.byte_size = 0; + metadata.byte_size = 1; grid.reset(); return true; } @@ -115,12 +115,16 @@ bool VDBImageLoader::load_metadata(const ImageDeviceFeatures &features, ImageMet #endif } -bool VDBImageLoader::load_pixels(const ImageMetaData & /*metadata*/, +bool VDBImageLoader::load_pixels(const ImageMetaData &metadata, void *pixels, const size_t /*pixels_size*/, const bool /*associate_alpha*/) { #ifdef WITH_NANOVDB + if (metadata.type == IMAGE_DATA_TYPE_NANOVDB_EMPTY) { + memset(pixels, 0, metadata.byte_size); + return true; + } if (nanogrid) { memcpy(pixels, nanogrid.data(), nanogrid.size()); return true; diff --git a/intern/cycles/scene/volume.cpp b/intern/cycles/scene/volume.cpp index 25ffe8e7884..a39743def66 100644 --- a/intern/cycles/scene/volume.cpp +++ b/intern/cycles/scene/volume.cpp @@ -21,6 +21,7 @@ #include "util/nanovdb.h" #include "util/path.h" #include "util/progress.h" +#include "util/texture.h" #include "util/types.h" #include "bvh/octree.h" @@ -487,6 +488,7 @@ void GeometryManager::create_volume_mesh(const Scene *scene, Volume *volume, Pro /* Create NanoVDB grid handle from texture memory. */ device_texture *texture = handle.image_memory(); if (texture == nullptr || texture->host_pointer == nullptr || + texture->info.data_type == IMAGE_DATA_TYPE_NANOVDB_EMPTY || !is_nanovdb_type(texture->info.data_type)) { continue;