Stone Shire in Unreal Engine 5

Read More

For the past few months, I’ve been messing around with Unreal Engine 5 since it has become a hot commodity. Unity is fine, but I’m more at home around C++. Not to mention, I like more of the low level access you can get from Unreal vs Unity where they locked out a lot. I’ve been “porting” Stone Shire to Unreal as an exercise to practice with the engine. It has been a wild journey so far, but I’ve gotten the basics of it set up with proper code organization and actor usage. Procedural generation makes use of the the UProceduralMeshComponent class, which has been very helpful.

One big obstacle I’ve had to overcome is that the cartesian coordinate system in Unreal is far different from Unity. In Unity, Y is up and down. In Unreal, Z is up and down. In addition, the texture coordinate system has the origin in the upper left instead of the bottom left. This has made me have to change around a lot of how I organized my vertices and uvs, but I managed to fix it after an hour.

As Tim Sweeney from Epic Games said:

In any case, I have the game practically running. But now I still need to add more of the basics from my Unity project: generating a world procedurally, editing and putting down cubes, and all the other fun stuff in a Minecraft-like game. I will say one thing: the first-person module that comes with Unreal is far more friendly than the basic one in Unity. I love all the little details like the automatic sloping effects of the physics engine, so you can go up and down threshold of heights a lot better. I know this is in Unity in some form, but it’s “smoother” in Unreal Engine 5.

Hello World version of Stone Shire

Stone Shire Update April

stoneshire-update-4-16-22

I’ve been using my side time from the main job to work on the Stone Shire engine some more. I finally got infinite functionality working in Unity, along with a save and load system which I still need to optimize to save entire regions rather than just individual chunks. Minecraft uses this system to lessen reads and writes, so I intend to do the same. I basically have rewritten the engine from the ground up refactoring a lot of code. I hope to have this out on Steam at some point as Early Access. Nintendo stopped selling on the eshop from the Wii U, so the game is no longer available there. A good excuse for me to update and get it onto PC. I intend to make this into the Dwarf Fortress 3D game that I imagined at the beginning.

Cor

Day & Night Update

The previous approach didn’t agree well with Unity’s way of rendering, so I settled with just going with the old fashioned shader method of shifting through the time cycles of day and night. It looks beautiful either way, and I’m happy enough with that. The sky looks a little bland, so the next step is adding some gradient and procedural clouds. Then after that, my favorite: weather. I still need to reintegrate different biome regions in the game. I’ll also need to do some chunk loading/ unloading optimizing to allow the game to not eat at memory at large scales. It’ll use the “generate on demand” method that Minecraft uses, while saving preloaded data to the disk. This should save a lot of memory. At the same time, the game won’t have infinite generation, so may end up doing a preload method where the entire world is saved to disk on creation of new world, but only the visible parts are kept in memory. I’ll play around with that.

Stone Shire Coming to Steam

I am currently working on releasing an Early Access build of Stone Shire to Steam for PC. It has been a while since I’ve tackled this project since the Nintendo Wii U, but I made a lot of adjustments over the last two weeks as I returned to it. A lot of code clean up and optimizations that I missed the last time. For one, in the video above, I am making a “sweeping” method for when the sun rises or sets. In real life, this is how the lighting usually looks. And I know in Minecraft, they simply blend the colors into the landscape. But I wanted to go with a more cool approach that simulates what happens in real life. It works smoothly in game and looks pretty cool as the environment changes lighting and color over time.

Making a voxel game in Unity is not an easy feat considering you don’t have a lot of low level access to the hardware as say a language like C++. Stuff like thread management is a big one when it comes to Unity, since everything runs on the main thread, something that still annoys me about the engine. I wish that they tackle this as a feature in a future edition. Being able to have closer control to the main thread functionality with Unity methods would greatly increase performance of voxel rendering. For now, I just throw all the math, voxel, and lighting calculations on a System.Thread from the C# size and then pass them all to the Main Thread when it’s time to do the assignments to meshes.

Still, I’ve made do with what I have. Chunks are no longer created and destroyed naively, but rather, a pool of chunks are drawn from now that the system recycles through. No more choppy updates while moving across the land. Water flow has been turned back on, including optimizing its flowing, which killed Wii U performance. Currently implementing day and night cycles, along with weather next. After that, returning large maps with multiple biomes. I had this in an earlier build, but I had to restrict the size of the map for Wii U, thus turned the feature off. So this should be as simple as flicking it back on. I think.

– Cor