Chunk Class for Unity Voxel Engine (Example)


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.



Creating a grid mesh programmatically in Unity 3D


Accessing strings in c++ from c#


Scenario; You may have some c++ code you wish to output string data to be used in a c# application.

SQL to JSON with C#


This seems to work quite well. If there is a more efficient way please let me know.

php mysql database connection


Connecting to mysql via php.

this is nice to keep in a separate file (inc/conn.php) which can be included into other pages via;

upload via FTP with c#


Quick and easy way to get files uploaded with c#;

Some old voxel lighting code


If you look at some of the previous posts you will see this code or a variant of it in use. It may be useful to some. It is very much a hack and i hope to revisit it perhaps in c++ or java.

LWJGL OpenGL VBO Issue on Linux


I struggled for a while with some code that generates 2 triangles using indices with more modern OpenGL methods. It worked fine when run on my windows boxes but not on my 2011 MBP running linux. There were no errors or anything i could see (i may not have configured the error checking correctly)

The issue was resolved by replacing the video driver. The xorg driver while it did support some OpenGL functions, did not apparently allow VBO. So if you notice issue with VBO/VBA code on linux where it runs fine on windows, try swapping out your graphics card drivers.

Below is the code used for the loader class thanks to ThinMatrix @ youtube who has some excellent tutorials for lwjgl.

Compressing Voxel Data


My first attempt at saving and loading voxel data seems to work reasonably well. It manages to save approx 4 million voxel points in about 64kb which seems reasonable. The compression ratio would decrease as the usefulness of RLE (Run Length Encoding) wanes due to excessive fragmentation. What remains to be done is to only save those blocks that have changed along with the seed. I’m not building never ending minecraft type worlds so i’m dealing with known quantities here. Currently it just savesĀ and loads everything, surprising quickly.

Lighting Test


Rewrote ambient occlusion and built a light spreading system.
This is a long way from NVIDIA’s new global illumination/maxwell ‘voxel’ based lighting i read about recently but I’m gradually improving the light system for this unity engine.

I still need to build a more efficient way to update chunks that have had light changed due to light spreading from another chunk.

I use a system of stacks (all chunks on vertical axis) and chunks. When a block is placed or removed the stack should have light recalculated and mesh rebuilt. If light values change in chunks not within this stack, then those chunks should be rebuilt. I’m probably still missing a few things but I’ll keep working on it.