mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-20 06:35:36 +08:00
feat(splatfacto): record antialiased mode as SplatRenderMode PLY comment
On Gaussian Splat export, write a 'SplatRenderMode: mip|default' PLY header comment derived from the model's rasterize_mode so viewers can select a matching rasterization mode. 'mip' is the antialiased mode; 'default' is classic. - ExportGaussianSplat.write_ply gains an optional 'antialiased' arg (None keeps the previous no-comment behavior); export main() passes model.config.rasterize_mode == 'antialiased' - splatfacto exposes rasterize_mode as a disabled/frozen viewer dropdown (the viewer renders the live model, so the mode is read from config) - add a test asserting the comment is written for mip/default/none
This commit is contained in:
1 parent
50e0e3c70c
commit
5e788b38d4
3 files changed
+74
-1
No files matched your search
@@ -76,6 +76,45 @@ def test_export_gaussian_splat_write_ply_mismatched_count(tmp_path: Path):
|
||||
ExportGaussianSplat.write_ply(filename, count, map_to_tensors)
|
||||
|
||||
|
||||
def _read_ply_header(filename: str) -> str:
|
||||
"""Return the ASCII PLY header (up to and including the end_header line)."""
|
||||
with open(filename, "rb") as f:
|
||||
data = f.read()
|
||||
end = data.index(b"end_header")
|
||||
return data[:end].decode("ascii")
|
||||
|
||||
|
||||
def _make_valid_tensors(count: int = 10) -> "OrderedDict[str, np.ndarray]":
|
||||
return OrderedDict(
|
||||
[
|
||||
("x", np.random.rand(count).astype(np.float32)),
|
||||
("y", np.random.rand(count).astype(np.float32)),
|
||||
("z", np.random.rand(count).astype(np.float32)),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_export_gaussian_splat_write_ply_render_mode_comment(tmp_path: Path):
|
||||
count = 10
|
||||
|
||||
# antialiased=True -> mip
|
||||
mip_file = str(tmp_path / "mip.ply")
|
||||
ExportGaussianSplat.write_ply(mip_file, count, _make_valid_tensors(count), antialiased=True)
|
||||
assert "comment SplatRenderMode: mip" in _read_ply_header(mip_file)
|
||||
|
||||
# antialiased=False -> default
|
||||
default_file = str(tmp_path / "default.ply")
|
||||
ExportGaussianSplat.write_ply(default_file, count, _make_valid_tensors(count), antialiased=False)
|
||||
header = _read_ply_header(default_file)
|
||||
assert "comment SplatRenderMode: default" in header
|
||||
assert "comment SplatRenderMode: mip" not in header
|
||||
|
||||
# antialiased=None (default) -> no SplatRenderMode comment (backwards compatible)
|
||||
none_file = str(tmp_path / "none.ply")
|
||||
ExportGaussianSplat.write_ply(none_file, count, _make_valid_tensors(count))
|
||||
assert "SplatRenderMode" not in _read_ply_header(none_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run the test
|
||||
test_export_gaussian_splat_write_ply(Path("."))
|
||||
|
||||
Reference in new issue
Block a user