diff --git a/tsd/src/tsd/io/importers/import_NVDB.cpp b/tsd/src/tsd/io/importers/import_NVDB.cpp index 53e7433d..89750231 100644 --- a/tsd/src/tsd/io/importers/import_NVDB.cpp +++ b/tsd/src/tsd/io/importers/import_NVDB.cpp @@ -30,6 +30,34 @@ SpatialFieldRef import_NVDB(Scene &scene, const char *filepath) try { auto grid = nanovdb::io::readGrid(filepath); auto metadata = grid.gridMetaData(); + + bool hasActiveVoxels = false; + switch (metadata->gridType()) { + case nanovdb::GridType::Fp4: + hasActiveVoxels = grid.grid()->activeVoxelCount() > 0; + break; + case nanovdb::GridType::Fp8: + hasActiveVoxels = grid.grid()->activeVoxelCount() > 0; + break; + case nanovdb::GridType::Fp16: + hasActiveVoxels = grid.grid()->activeVoxelCount() > 0; + break; + case nanovdb::GridType::FpN: + hasActiveVoxels = grid.grid()->activeVoxelCount() > 0; + break; + case nanovdb::GridType::Float: + hasActiveVoxels = grid.grid()->activeVoxelCount() > 0; + break; + default: + break; + } + + if (!hasActiveVoxels) { + logStatus("[import_NVDB] no active voxels, skipping '%s'", filepath); + scene.removeObject(field.data()); + return {}; + } + if (!metadata->hasMinMax()) { switch (metadata->gridType()) { case nanovdb::GridType::Fp4: { diff --git a/tsd/src/tsd/io/importers/import_USD.cpp b/tsd/src/tsd/io/importers/import_USD.cpp index e30ce42f..2f1b2620 100644 --- a/tsd/src/tsd/io/importers/import_USD.cpp +++ b/tsd/src/tsd/io/importers/import_USD.cpp @@ -910,7 +910,8 @@ static void import_usd_volume(Scene &scene, VolumeTransferFunction tf = get_volume_transfer_function(prim); ArrayRef colorArray; - math::float2 valueRange; + // Default to the field's value range to avoid undefined ranges. + math::float2 valueRange = field->computeValueRange(); // Create a volume node and assign the field, color map, and value range auto [inst, volume] = scene.insertNewChildObjectNode( @@ -922,7 +923,8 @@ static void import_usd_volume(Scene &scene, // Use transfer function from USD material colorArray = scene.createArray(ANARI_FLOAT32_VEC4, tf.colors.size()); colorArray->setData(tf.colors.data(), tf.colors.size()); - valueRange = tf.domain; + if (tf.domain.x < tf.domain.y) + valueRange = tf.domain; // Create opacity control points from USD transfer function std::vector opacityControlPoints;