Project Voxelscape [Now Open Source!]

Hello all. I’ve been working on a voxel engine for some time now and recently switched from Unity3D to Xenko for that modern C# experience. Async/await and modern threading libraries proved to be an absolute must for my project and C# 3.5 just couldn’t cut it any longer.

Check out this video to see it in action; https://www.youtube.com/watch?v=whJOtux2DrQ

Now released open source! https://bitbucket.org/LyingDwarf/xenko-voxelscape/src/master/

Built with Xenko 3.0.0.9, but can’t run in the GameEditor. Only runs from the XenkoVoxelscape.sln and only in Debug mode. No longer being actively worked on. Only demonstrates procedurally generating sky islands. No runtime editing of voxels and no physical collisions.

8 Likes

I too have a Unity3d project that relies heavily on proc gen meshes like your’s. How hard is it to generate your mesh in Xenko? What difficulties did you have porting from one to the other. I too am having issues with garbage collection along with some other things affecting performance and was looking into Xenko but issues like your’s with the collision mesh etc are making me hesitant so I curious how you experience has been.

I’ll be responding in depth on your other posting :wink:

Sorry the blog is down for now, but you can still see the engine running here; https://www.youtube.com/watch?v=whJOtux2DrQ

As I’m no longer actively developing this project I’ve decided to release it as is under the open source MIT license. For anyone interested in voxels and procedural generation I hope you can find something useful here. https://bitbucket.org/LyingDwarf/xenko-voxelscape/src/master/

I last worked on this over a year ago so getting it to run again has proven a little tricky. I’ve updated it to work with Xenko 3.0.0.9, but I can’t get it to run from the GameEditor because of some Nuget error. It only runs from the XenkoVoxelscape.sln opened in Visual Studio and only in Debug mode. In Release mode I get a NullReferenceException, no idea why. If someone could provide some help with that and the Nuget error it’d be much appreciated.

4 Likes

Thanks @LyingDwarf.

Even though you seem to have abandoned GitHub, I have created a fork there: https://github.com/Kryptos-FR/Xenko-Voxelscape as I don’t have a bitbucket account nor plan to create one.

1 Like

That is pretty awesome. Great of you to share it @LyingDwarf

1 Like

How can we make this have a visual indicate into a (entity) node within Xenko. That way I can have a idea on what areas terrain generates at that way I an properly place assets.

I’m sorry but I honestly don’t know. The voxel engine was not designed with the GameEditor in mind and as stated above I can’t even get it to run inside the GameEditor right now. It doesn’t support loading and unloading other game assets as the player moves around.

Hello, I noticed in the video you brought up a numerical menu to generate the seed type (seen at 1:48 in the video). How does one bring up that same menu? Also wanted to know if it is possible to generate voxels based on a 2D template. That way I can layout assets in Xenko without having to worry about clipping objects to the terrain.

Looking back over the code it appears that functionality was removed during some refactor. But if you’re ready to dive into the code, Voxelscape.Xenko.Game.Scenes.Streaming.StreamingSceneController is where the high level setup of the scene is done. The call to StreamingStageMeshFactory.CreateSkyIsland() on line 64 could be changed to be given a seed value, and stageEntity declared on line 77 is what holds the current voxel world. By destroying that entity and making a new one with the new seed you’d get a different voxel world generated.

The sky islands are actually generated according to a set of 2D height maps. However, those maps are also procedurally generated and there was no functionality added for loading any kind of standard height map data. On the subject of missing functionality, and as an up front warning here, this voxel engine also doesn’t have working physics collision yet and doesn’t have the ability to change voxels at runtime (no digging or building). This really is only meant as a demo of random world generation.

I wonder if it is possible to generate a minimap view for something like this. (Would make a nice start for a platformer game).

Sorry about the delayed response. I do still watch this thread and repository, just been a busy couple of weeks.

You absolutely could generate a presumably top down minimap view of the voxel world. The voxels are accessed in what appears to the programmer like an infinitely sized 3D array. So for each pixel you want to fill in on the minimap you could check the corresponding voxel index in the 3D array to see what’s there (assuming 1 minimap pixel equals 1 voxel for simplicity). Each voxel type has a definition for what color/texture it is so you could use that to determine what color to fill in the minimap pixel with. The height of the voxel index could be used to lighten or darker the minimap pixel to give a sense of elevation in the map.

One complication is that the voxels are 3D and ‘infinitely’ tall and you don’t know immediately where the ground level is in the voxels. If you’re making a game with a static premade world or a sandbox with a maximum build height you could start from that ceiling height and check downwards, moving 1 voxel at a time until you find something that’s not an empty air voxel and then assume that’s the ground to fill in the minimap with. For a more dynamic/limitless game you could pick some arbitrary height above the player’s current position and starting checking from there. Alternatively, you could start from the player’s feet since they’re likely on the ground and start checking from there. Each approach has different limitations and tradeoffs in terms of fringe case oddities and performance.

Or you could skip past the voxels entirely and use the heightmaps, at least in the case of this particular world generator. My previous post mentions that the sky islands are generated using a set of 2D height maps. While these height maps don’t tell you exactly what the shapes of islands are because there is other 3D noise added in to make it more varied, the height maps do give you a pretty good approximation of the shape and they’re already 2D just like the minimap. No more need to search for the ground height in the 3D voxel data. This only works because this generation algorithm uses height maps and even keeps them loaded into memory. But if the game world can change over time, for instance by the player creating and destroying terrain, the heightmaps don’t ever update to reflect that and the minimap wouldn’t either.

I hope this has provided some interesting insight to the possibilities and the way the engine works.

1 Like

Is it possible to generate terrain on top of a object node?
Can pathway generation be a thing something less randomized?

How would you go about making a character object collide (land) on the terrain? Where would one need to look to accomplish that.

Last question would be is how do you assign a texture type on a voxel lets say a character or object collides with a voxel can that function be used to effect the voxel or voxel type?

Not sure I quite understand what’s being asked by generating on top of an object node and by pathway generation. It’s been years since I’ve used Xenko.

As for for making a character collide with the terrain, that was a feature I never got around to implementing. That is either going to be trivial or incredibly difficult depending on what Xenko supports. The voxel engine is generating meshes already, so all you need is the ability to do physics/collisions against those meshes. However, these are concave meshes and not manifold. I know some physics libraries allow mesh collision checking but only with convex meshes. You’d need to look into what Xenko supports and how to use those features, or you’d have to integrate a different solution to collision / physics entirely.

Texturing was another feature I never finished and sadly can’t provide much help with. Because all the voxels are contoured out into the same shared mesh you’d need a texture atlas (or texture array) that can contain all your different textures in a single material applied to that mesh. Then you’d need to generate the correct UV coordinates for each vertex in the mesh to select the correct ‘sub texture’ from the atlas/array. I think the voxel engine may already do this, but I never finished the texture atlas/array and associated shaders to make it work.

Its probably even harder now that we’ve updated to Stride3D ive been using the template for awhile as well. (Takes a-lot of time navigating around via code wise) also considering I don’t have that much coding experience to really allocate this particular template.

Currently im looking at this as an alternative way of platforming. Also the previous statement was (Instead of having the voxels spawn everywhere is it possible to have it spawn on top of a object (like a cube mesh or anything other asset I decide to create). I’m using meshes as a point of reference for different zones in my game.