hi everybody , after getting my hands on cubiquity voxel engine i started wondering how it was made and what exactly goes into a voxel engine , so for last 2 months ive been developing a voxel engine , what i have so far is , infinite loading of chunks (virtually forever) , fast chunk loading , low memory usage (1mb per metre view distance) still needs work on the memory but its and easy fix by my estimates i should be able to drop that to about 300kb or less , i also have a very wip voxel chunk saver which stores the voxel values for now it only stores changed chunks (chunks that have been edited during run time),there’s also editing of the voxels during runtime at decent speed , there’s no lag or frame rate drops as the chunks are loaded due to it being fully mutithreaded . If i manage to reduce the memory usage and improve load times i’ll put it up on the assetstore.
the original code was created Scrawk i read his blog from beginning to end it helped me understand all the code i suggest you guys go check it out http://scrawkblog.com/ , credit to him for the original scripts , i have expanded it quite a bit optimized where i could ,still alot to do but so far its working well , ive only been coding for 8 months so this is all still quite new to me.
,heres some screenshots of the landscape that it generates.
upcoming features:
better texturing of terrain based on voxel material eg: sand , grass ,stone , iron.
level of detail system with seams and skirts although skirts seem easier but its to be investigated.
collapsing voxels based on amount of stress from above, this ones optional but it could be fun to code .
storing voxels on disk instead of in ram to reduce memory usage , this ones gonna be tricky need to find a way of compressing the data to disk and decompressing when needed ( for editing and other purposes) .
thats all for now any questions or features you’d like to see in here ask away.
thank you hopefully i get it right , yes it is , ive seen your thread pretty interesting stuff , if you dont mind me asking , did you do texturing based on slope or based on voxel type , if its the later how did you manage it ? ive tried a couple techniques and they all slow , none the less some interesting stuff there.
sorry for the long delay Internets been down for a couple days .
Ive managed to implement a grass system which use Graphics.DrawMesh which actually allows for batching of the meshes and uses no memory at all besides the one mesh .
What ive done is drawn one mesh multiple times in multiple locations , this way it batches well and alllows for an insane density of grass and meshes to be drawn so far i haven’t tested the density , but from what i can tell the system works well.
That’s all for now .
cheers
Edit: Having tested the density i can confirm that you can have 800 or more grass meshes per chunk, by my estimates if you had a decent gpu as apposed to my punny amd 6670 i think you could do much better by my estimates 2000 meshes per chunk , if there are 6 different types of meshes, you can also use any mesh you want in the terrain,i havent tried yet but trees could also be done this way although i prefer using another method to do trees as they have colliders.
id like to put up a demo incase people wanna test it out , if anybody would be interested in testing it out for me do let me know. thanks.
heres a screenshot of it the new grass renderer renderering about 15000 meshes at once ,granted the framerate is low , so it could use some more optimization , what still needs to be done is only rendering those objects which the player can see , but so far it seems fine and memory usage is super low .
Update: Framerate has increased from 4 to 20 frames, by disabling shadows on grass i gained quite a few frames , Note this is on an old core 2 duo and an amd 6670 so performance should be much better on more modern hardware.
I’m using multiple inputs for texturing and shading including voxel types and geometry attributes. Triplanar shading based on voxel types is a good starting point, but a brute-force approach to triplanar shading using multiple textures gets expensive quickly.
I’ve written my terrain shader so it pre-calculates certain parts of the triplanar equation only once per pixel. This works because the normal and world position is the same for every texture type for that pixel, with only the tiling changing from texture to texture.
Did you happen to do the “threshold optimization” of your shader? For texture blending shaders, I always look at a texture’s contribution coefficient, and if it is below a certain threshold (for example 0.05), I don’t bother doing a texel lookup or including it in the surface color/normal/specular calculations.
thanks for responding , ill have to do some reading up on all that as it mostly went over my head , ive been looking into thresholds and its a bit tricky but ill get it figured out , ive also tried normal mapping and so far it just seems to twist the textures and blur the terrain , ill have to make a thread on the shader forum , anyway thanks for the response , also im using my phone so sorry for the poorly written response .
ive been doing some research into voxel water and ive decided to start development on it , itll be combined with this terrain , it will flow , kind of like minecraft water one update per second or so maybe more , hopefully i can create it with decent performance .
thats all cheers
Hi , those floating islands are all generated by the voxelengine , its strange behaviour but I thought it looked cool so I left it , if you don’t want tonuse them all you gotta do is fiddle with the noise values a bit , hope that helps .
Right , an update I’ve managed yo get the texturing working perfectly now based on voxel type , I’ve also managed to create my own voxel saver which only uses the chunk dimensions as memory , like so , if your chunk is 32 wide by 128 high by 32 long then the memory usage of that chunk is 3212832=131072 bytes so that’s all good cause now I can start work on only keeping certain voxel data in memory while all other data gets stored to disk .
no that extremly interesting as i looked for a way to make this type of island in the sky, do you have control over the genral shapes of the chunks ? for example if you want more mountains or hills, more cave or no cave at all ?
Yes you have complete control over the terrain although the island in the sky will be a bit tricky but its just fiddling with the noise values I guess , you can create normal islands , floating islands , caves anything you want really , I’m working on a system where you can plug any type of noise into the terrain engine or combine them via the use of modules that you select from a drop down menu .
Ive been hard at work trying to implement lod support as well as trying out some other techniques such as dual contouring and surface nets , so far progress is slow to non existent , but ive fixed all the bugs within the program , only thing left to do is make it usable by the common unity user and write up some documentation then i should be putting it up on the assetstore soon .
another update for those still following my progress , im still working on the terrain , as of now ive implemented touch bending on the grass which i thought looks pretty good , im still working on reducing fps in the grass renderer , seems ill have to combine the meshes at runtime to save on drawcalls cause as of now the draw calls are just to high , ill update when i can.