Can anyone suggest a fast, efficient method for storing and accessing a sparse octree?
Preferably something that can be easily implemented in HLSL. (I'm working a raycasting/voxel app)
In this instance, the tree can be precalculated, so I'm mostly concerned with size and search time.
Update
For anyone looking to do this, a more efficient solution may be to store the nodes as a linear octree generated with a Z-order curve/Morton tree. Doing so eliminates storage of inner nodes, but may require cross-referencing the linear tree array with a second "data texture," containing information about the individual voxel.
I'm not very experienced at HLSL, so I'm not sure this will meet your needs, here are my thoughts. Let me know if something here is not sane for your needs - I'd like to discuss so maybe I can learn something myself.
So, first, build the octree and stuff it with your objects. Then, just walk the octree, outputting the vectors to a memory buffer.
I'm thinking that a 512x512 texture can hold a fully packed octree 5 levels deep (32,768 nodes), each containing 8 objects. Or, a fully packed 4-level octree with 64 objects each.
There is a great article about sparse octrees focusing on GPUs: Efficient Sparse Voxel Octrees – Analysis, Extensions, and Implementation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With