Skip to content

Expose evaluate_spherical_harmonics in Python bindings#431

Merged
swahtz merged 6 commits into
openvdb:mainfrom
swahtz:eval_sh_binding
Jan 29, 2026
Merged

Expose evaluate_spherical_harmonics in Python bindings#431
swahtz merged 6 commits into
openvdb:mainfrom
swahtz:eval_sh_binding

Conversation

@swahtz

@swahtz swahtz commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

This PR provides a python binding for evaluate_spherical_harmonics as a standalone function as well as add pytests for the functionality.

This is useful in particular pipelines, for instance GARfVDB segmentation, where we want to be efficient about reusing projection results when rasterizing multiple times for different quantities. For instance, to reduce the time it takes to perform trilinear sampling during inference of the model, we can reduce the number of points we sample by only sampling points which are in frustum, not very small, etc. (i.e. the projected radii <=0). After grid feature sampling, we then could reuse the projection results (often expensive) if we could construct a renderable quantity of the new, higher channel count features and substitute this quantity in the ProjectedGaussianSplats. However, to do that we need to perform spherical harmonic evaluation. Instead of writing an equivalent utility function in python, it seems more sensible to expose the functionality we've already written/tested.

Add tests for new bindings

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 exposes the evaluate_spherical_harmonics function as a standalone Python binding, enabling users to efficiently reuse spherical harmonics evaluation for custom Gaussian splatting pipelines. This is particularly useful for workflows that need to reuse projection results when rasterizing multiple quantities, such as in GARfVDB segmentation.

Changes:

  • Added Python binding for evaluate_spherical_harmonics in C++ with proper documentation
  • Added comprehensive unit tests covering various degrees, gradient flow, masking, and edge cases
  • Updated type stub files and module exports to expose the new function

Reviewed changes

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

Show a summary per file
File Description
src/python/GaussianSplatBinding.cpp Adds Python binding with lambda wrapper that calls the C++ autograd function, includes comprehensive docstring
fvdb/_fvdb_cpp.pyi Adds type stub for the C++ binding with proper type annotations
fvdb/__init__.pyi Adds type stub for the public API
fvdb/__init__.py Imports and exports the new function in the module's __all__ list
tests/unit/test_gaussian_splat_3d.py Adds comprehensive test suite with 13 test cases covering basic functionality, gradient flow, masking, edge cases, and different configurations

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

Comment thread tests/unit/test_gaussian_splat_3d.py
…tions is not provided for SH degree>0

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
…or does not have a device' error is thrown when 'save_for_backward' is called

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
…th eval SH use in GaussianSplat3d

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread src/python/GaussianSplatBinding.cpp

@matthewdcong matthewdcong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@swahtz swahtz merged commit 6e814d6 into openvdb:main Jan 29, 2026
38 checks passed
@swahtz swahtz deleted the eval_sh_binding branch January 29, 2026 20:39
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.

3 participants