Octree and Transvoxel Test

Octree and Transvoxel Test

Andrew Peterson

54 года назад

408 Просмотров

This is a test I performed using the Transvoxel algorithm and an Octree.

A recursive algorithm fills out an Octree to a depth of 5 (6 including the root). Each cube in the octree gets filled with ground if the density value of an OpenSimplex noise generator is above 0, or air otherwise. Finally I run the Transvoxel algorithm on the data structure, where when it looks for the density at a specific point in space, it looks up in the Octree what the value of the block there is.

There are lots of problems with my current implementation.

First of all, the Octree is all pointer-based and all allocated on the heap, which leads to horrible cache coherency. If I split each Octree into 2 levels, each one containing something like 5 levels, I could dramatically cut down on the pointer-chasing.

Secondly, this is supposed to support a sparse voxel octree, but right now every single possible value is filled.

Thirdly, the Transvoxel library I'm using seems to support voxel-based structures, but I used the location-based density function rather than because I was a little confused on how it works.

Fourthly, there are gaps in between the octrees (you're seeing a 4x4x4 grid of them in the video) because the Transvoxel algorithm starts to act a little wacky if I don't shorten the blocks. I know how to fix this, I just need to run Transvoxel again on the octree's outer faces, edges, and vertices. I've decided to not fix it until I check out how this Transvoxel library supports voxel structures.

In the short-term, I'd like to quickly iterate on this so I can begin prototyping some game ideas. I don't want to get too bugged down on implementing the perfect voxel data structure until I know how I want it to work.

Built with #bevy and #rustlang .

I have a discord server here: https://discord.gg/yVSXNKjH22
Ссылки и html тэги не поддерживаются


Комментарии: