Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion threedgrut/export/scripts/ply_to_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def main():
conf = load_default_config()
model = MixtureOfGaussians(conf)

# 2. Use init_from_ply
# 2. Use init_from_ply (now with built-in SH auto-detection for Isaac Sim compatibility)
logger.info(f"Loading PLY with init_from_ply: {input_path}")
model.init_from_ply(str(input_path), init_model=False)

Expand Down
16 changes: 15 additions & 1 deletion threedgrut/export/usdz_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ def export(self, model: ExportableModel, output_path: Path,
logger.warning(f"Failed to apply normalizing transform: {e}")
normalizing_transform = np.eye(4)

# Auto-detect SH configuration for Isaac Sim compatibility
# Ensure radiance_sph_degree matches n_active_features to avoid performance issues
effective_radiance_sph_degree = conf.render.particle_radiance_sph_degree
if n_active_features == 0:
# DC-only case: force radiance_sph_degree to 0 for Isaac Sim performance
effective_radiance_sph_degree = 0
logger.info("Isaac Sim compatibility: setting radiance_sph_degree=0 for DC-only data")
elif n_active_features != conf.render.particle_radiance_sph_degree:
# SH degree mismatch: use the actual features available
effective_radiance_sph_degree = n_active_features
logger.info(f"Isaac Sim compatibility: adjusting radiance_sph_degree from {conf.render.particle_radiance_sph_degree} to {n_active_features}")
else:
logger.info(f"Using configured radiance_sph_degree={effective_radiance_sph_degree}")

# Set up common parameters
template_params = {
"positions": positions,
Expand All @@ -93,7 +107,7 @@ def export(self, model: ExportableModel, output_path: Path,
"rotation_activation": "normalize", # Always normalize for rotations
"density_kernel_density_clamping": conf.render.particle_kernel_density_clamping,
"density_kernel_min_response": conf.render.particle_kernel_min_response,
"radiance_sph_degree": conf.render.particle_radiance_sph_degree,
"radiance_sph_degree": effective_radiance_sph_degree,
"transmittance_threshold": conf.render.min_transmittance,
}

Expand Down
16 changes: 16 additions & 0 deletions threedgrut/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,22 @@ def init_from_ply(self, mogt_path:str, init_model=True):

extra_f_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("f_rest_")]
extra_f_names = sorted(extra_f_names, key = lambda x: int(x.split('_')[-1]))

# Auto-detect SH degree for Isaac Sim compatibility
if len(extra_f_names) == 0:
# DC-only PLY: automatically set max_n_features to 0
if self.max_n_features != 0:
print(f"Auto-detected DC-only PLY file: adjusting max_n_features from {self.max_n_features} to 0 for Isaac Sim compatibility")
self.max_n_features = 0
elif len(extra_f_names) % 3 == 0:
# Infer SH degree from available f_rest properties
num_speculars_available = len(extra_f_names) // 3
import math
inferred_degree = int(round(math.sqrt(num_speculars_available + 1) - 1))
if self.max_n_features != inferred_degree:
print(f"Auto-detected SH degree {inferred_degree} from PLY file: adjusting max_n_features from {self.max_n_features} to {inferred_degree}")
self.max_n_features = inferred_degree

num_speculars = (self.max_n_features + 1) ** 2 - 1
assert len(extra_f_names)==3*num_speculars
mogt_specular = np.zeros((num_gaussians, len(extra_f_names)))
Expand Down