Fix #144543: Cycles NanoVDB render error with empty volume grid

Thanks to Weizhen for finding the cause.

Pull Request: https://projects.blender.org/blender/blender/pulls/144735
This commit is contained in:
Brecht Van Lommel
2025-08-18 20:21:44 +02:00
committed by Brecht Van Lommel
parent 05c7ec3a2f
commit 6d6c950750
2 changed files with 8 additions and 2 deletions

View File

@@ -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;

View File

@@ -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;