splat-transform
splat-transform使用指南
背景
splat-transform是面向 Aholo Viewer 的 3DGS 处理工具,用于格式转换、数据简化、LOD 生成和体素碰撞体生成。
环境需求
- Node.js >= 20.19.0
- Windows: Windows 22H2+,x86_64,D3D12 或 Vulkan 兼容显卡。需要 GPU 功能时,建议使用独立显卡。
- Linux: x86_64,glibc >= 2.34,libstdc++ >= 3.4.30,Vulkan 兼容显卡。需要 GPU 功能时,建议使用独立显卡。
- macOS: 暂不支持。
需要GPU的功能
- SOG 生成。
- Voxel 生成,且
backend设置为gpu。
格式说明
输入格式
plysogksplatsplatspzlcccompressed.ply,即 supersplat 压缩 plymeta.json,即 sog 未打包 meta 数据
输出格式
plyspzuspz,即未 gzip 的 spzsplatsog
modify格式说明
{
isRowMatrix: boolean; // 确认行矩阵或列矩阵,默认为 true
transform: number[]; // model级别的变换
deletedIndices: number[]; // 删除的下标,bitmap形式
indicesTransform: Array<{ indices: number[]; transform: number[] }>; // 局部变换的列表
}
使用方式
如何安装
npm install @manycore/aholo-splat-transform -g
CLI 模式
splat-transform create <input> <output> # 转换3DGS格式
splat-transform lod:auto --ratio <ratio> <input> <output> # 简化3DGS到指定比例 ratio [0-1]
splat-transform lod:auto-chunk --type <type:ply,spz,splat,sog> --max-chunk-counts <count> <input> <output> # 生成可以被调度的多级别lod数据,--max-chunk-counts 最大分块大小
pipeline 模式(推荐)
splat-transform pipeline.json
pipeline 描述文件(pipeline.json)
{
"version": 1,
"tasks": [
{
"id": "0",
"type": "Read",
"config": { "inputs": ["a.ply"], "output": "cache0" }
},
{
"id": "1",
"type": "AutoChunkLod",
"config": { "input": "cache0", "output": "cache0", "type": "spz" }
},
{
"id": "2",
"type": "Write",
"config": { "input": "cache0", "output": "a-lod" }
}
]
}
Task
| 名称 | 功能 | 参数 | 类型 | 必须(默认值) | 说明 |
|---|---|---|---|---|---|
| Read | 读取多个高斯文件并且合并成一个SplatData对象 | inputs | string[] | Y | 输入的文件路径 |
| output | string | Y | 写入资源key | ||
| maxShDegree | number 0..=3 |
N(3) | 最大球协阶数 | ||
| Write | 将SplatData对象按指定格式存储到磁盘 | input | string | Y | 读取资源key |
| output | string | Y | 写出资源路径 | ||
| compressLevel | number 0..=9 |
N(6) | gzip压缩level | ||
| enableMortonSort | boolean | N(true) | 开启莫顿排序 | ||
| Modify | 修改SplatData对象 | input | string | Y | 读取资源key |
| output | string | Y | 写入资源key | ||
| modifyPaths | string[] | N([]) | modify json 文件路径 格式参考modify格式说明 |
||
| AutoLod | 生成融合高斯结果 | input | string | Y | 读取资源key |
| output | string | Y | 写入资源key | ||
| counts | number | N(Infinity) | 最大保留数量 | ||
| ratio | number 0..=1 |
N(0.3) | 最大保留比例 | ||
| AutoChunkLod | 生成分块融合高斯结果,使用需要结合lod调度模块 | input | string | Y | 读取资源key |
| output | string | Y | 写入资源key | ||
| type | string | Y | chunk的文件类型,参考输出格式 | ||
| forceSpzFormatThreshold | number | N(0) | 目前由于数量少的场景下sog的压缩率很差,所以增加了这个参数,低于这个参数的chunk会强制转换成spz格式,建议实际中设置 200000 | ||
| maxChunkCounts | number | N(400000) | chunk的最大高斯点数量 | ||
| levels |
|
N
|
chunk的最大高斯点数量 | ||
| Voxel | 生成体素碰撞体 | input | string | Y | 读取资源key |
| output | string | Y | 输出文件路径 | ||
| voxelResolution | number | N(0.05) | 体素尺寸 | ||
| opacityCutoff | number | N(0.1) | 体素筛选阈值,值越高体素越容易被剔除,漂浮物多的方案可以适当提高此值 | ||
| backend |
string
|
N(gpu) | 生成方式,默认使用gpu,可选cpu。cpu的耗时会明显高于gpu。两者的结果会有细微差异。 | ||
| box |
|
N
|
场景box限制(离群点对体素化性能影响极大且其输出无意义,所以目前采用最简单的方案限制了体素的生成范围) | ||
| navCapsule |
|
N(null) | 两者均服务于导航简化功能。navCapsule用于设置导航体高度和半径,navSeed设置导航起始中心。 开启后,会将体素按照导航体可达范围进行简化,能够优化体素(未完善,部分情况下可能存在副作用所以默认不开启) | ||
| navSeed |
|
N(null) |
使用样例
- 把 a.ply 和 b.ply 应用修改以后转换成 c.spz
{ "version": 1, "tasks": [ { "id": "0", "type": "Read", "config": { "inputs": ["a.ply", "b.ply"], "output": "cache0" } }, { "id": "1", "type": "Modify", "config": { "input": "cache0", "output": "cache0", "modifyPaths": ["a.json","b.json"] } }, { "id": "2", "type": "Write", "config": { "input": "cache0", "output": "c.spz" } } ] } - 对 a.ply 应用修改以后生成 auto chunk lod
{ "version": 1, "tasks": [ { "id": "0", "type": "Read", "config": { "inputs": ["a.ply"], "output": "cache0" } }, { "id": "1", "type": "Modify", "config": { "input": "cache0", "output": "cache0", "modifyPaths": ["a.json"] } }, { "id": "2", "type": "AutoChunkLod", "config": { "input": "cache0", "output": "cache0", "type": "spz" } }, { "id": "3", "type": "Write", "config": { "input": "cache0", "output": "a-lod" } } ] } - 生成体素碰撞体
{ "version": 1, "tasks": [ { "id": "0", "type": "Read", "config": { "inputs": ["input.ply"], "output": "cache0" } }, { "id": "1", "type": "Voxel", "config": { "input": "cache0", "output": "voxel-output", "voxelResolution": 0.05, "opacityCutoff": 0.1, "navCapsule": { "height": 1.4, "radius": 0.2 }, "navSeed": { "x": 0, "y": 0, "z": 0 } } } ] }
注意事项
- 当需要生成
SOG或者使用GPU生成Voxel时,推荐使用性能较好的独立显卡。当转换比较大的数据到SOG时,需要10GB以上显存。 - 当生成
chunk-lod时(既使用AutoChunkLod或者lod:auto-chunk生成),推荐使用spz输出,在分块和多级lod后,会存在数据量很少数据量比较小的块,对于这些块sog压缩率表现不如spz,也可以配置forceSpzFormatThreshold来控制小于某个数量的块强制使用spz chunk-lod生成过程中对资源消耗比较大,推荐使用配置比较高的机器配置。对于大型数据推荐内存 >= 32GB, CPU核心数>=16(含超线程)。当无法直接生成时,可以先进行简单的块分割再生成,之后合并lod-meta.json,合并可以使用来自@manycore/aholo-splat-dev-server@>=1.0.1的merge-lod指令。