Surface nets – getting closer

Standard

I played around with the size of the various loops to get it to this point. I’m not sure how it works but there are no out of index errors. With marching cubes the chunk iterations were from 0 to chunkSize -1. There are some verts which cross over outside of their chunk’s zone, circled in red int he image below. I should be able to force them back onto the chunk edge but it’s not ideal.

Code changes;

Surface nets – some progress

Standard

A few minutes after the last post i realized my mistake. I’d mixed up the temporary Vector3 array with the production array.

The only things i changed from the previous code to get it to this point was swapping chunk.newVertices with chunk.vertices. Edit: I actually ended removing the swapped array altogether as i could find no area where it was referenced, result was the same.

Its still a way off, but hey.. its better!

 

 

Surface net code adaption failed attempt

Standard

As a reference this is how it looks in marching cubes mode;

How it appears in my first attempt with the surface nets.

More experimentation to come. I’m guessing i’ve made a few mistakes here.

The modified code (original code here )

Chunk Class for Unity Voxel Engine (Example)

Standard

Here’s an example of a Chunk class i use in some variants of the engine. This one is a bit experimental but working OK so far.

chunk

 

nVox

Standard

A voxel engine in c# and Unity 3D. Written from the ground up it’s been a fun learning experience so far. I have a better understanding now of 3D engines that use chunks to store data. Unity’s single main thread makes it a bit difficult to update collision data as fast as i would like. ¬†Terrain generation and lighting can all be multi-threaded but the unity game object is a real bottle neck so far. I’ve had to limit the amount of work i let it do to keep the frame rate reasonable.

screen