Skip to content

Conversation

@apaaris
Copy link
Member

@apaaris apaaris commented Jan 19, 2026

Hi everyone,
this PR fixes a bug that I've encountered when loading a large dataset composed by many nanovdbs. What happened is that when a nanovdb had no active voxel, it was rendered as a dark block.

With this PR I implemented a check that skips nanovdb volumes with no active voxel, effectively solving the problem. I think this should be fixed at source, not writing empty nanovdbs in the first place, however it is convenient in my opinion to also have this safety check in tsd.

@jeffamstutz @tarcila I'm happy to discuss the matter further if you would prefer a different solution

Have a great day,
A.

@tarcila tarcila requested review from Copilot and tarcila January 19, 2026 19:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses rendering issues with NanoVDB volumes that contain no active voxels, which previously appeared as dark blocks. The fix adds validation to skip empty grids and ensures proper value range initialization for USD volumes.

Changes:

  • Added active voxel count validation for NanoVDB grids to skip empty volumes
  • Fixed USD volume value range initialization to use field's computed range as default
  • Added conditional check for transfer function domain validity

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tsd/src/tsd/io/importers/import_USD.cpp Initializes value range with field's computed range and validates transfer function domain
tsd/src/tsd/io/importers/import_NVDB.cpp Adds active voxel count check to skip empty NanoVDB grids
Comments suppressed due to low confidence (1)

tsd/src/tsd/io/importers/import_NVDB.cpp:1

  • In the FpN case on line 46, the code incorrectly uses gridnanovdb::Fp16() instead of gridnanovdb::FpN(). This will return the wrong grid type's active voxel count for FpN grids.
// Copyright 2024-2025 NVIDIA Corporation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (!hasActiveVoxels) {
logStatus("[import_NVDB] no active voxels, skipping '%s'", filepath);
scene.removeObject(field.data());
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field object is being removed from the scene after it was just created. Consider skipping field creation entirely when there are no active voxels to avoid unnecessary object creation and cleanup overhead. Check for active voxels before creating the field object.

Copilot uses AI. Check for mistakes.
@tarcila
Copy link
Collaborator

tarcila commented Jan 19, 2026

@apaaris I am not sure that the change is the intended behavior. As far as I understood, an inactive voxel is expected to return the configured background value.

In common cases, that could be 0 or any value that maps to a fully transparent value in the transfer function, which would mimic the behavior that you implement there, by actually skipping that "empty" space.

Now if that value does not map to a fully transparent color, then we'd be creating block-shaped holes in the rendering.

I would suspect that an invalid data range is what could be creating that black rendering you observe. Maybe setting the range to the background value (grid.grid<GridT>()->tree().background();) would be enough? Can you test if this helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants