Asteroid Generation

Posted by Adam on 3 January 2022 at 12:23 pm

Something I usually do is have an idea and commit to creating a full product for it. The ideas don't stop coming though, and when you commit all your time to one idea, there's an opportunity cost in not being able to work on other ideas. While regaining my game development knowledge following my two and a half year hiatus, rather than lock myself into a game, I'm going to spend it creating proofs of concepts instead. When I have an idea, I'll strip it down to the bare concept, and build it, write about it, and then continue on.

Today's post is about an idea I had for randomly generated asteroids. I have an idea for a whole space-based roguelike, but for now that'll remain just a potential game, and instead, I've plucked one aspect of it out.

Sebastian Lague has a great video series on planet generation and it seemed to me that I could adopt some of that to work for asteroids. There wouldn't need to be any height-based terrain colouring or custom shaders, but his idea of using a cube and setting the vertices to normalised vectors to create a sphere, and then applying noise over this was really smart.

I did something similar, and while not perfect (the seems are visible at lower resolution), I was able to create an asteroid class that generates random asteroids with varying levels of resolution and shape. At a resolution of 4, that's 9 quads per side, or 108 triangles per asteroid, which gives quite a blocky look.

Randomly generated asteroid with a resolution of 4

At a resolution of 8, you have 49 quads per side, or 588 triangles in total.

Randomly generated asteroid with a resolution of 8

At a resolution of 16, you have 225 quads per side, or 2,700 triangles in total.

Randomly generated asteroid with a resolution of 16

At a resolution of 32, you have 961 quads per side, or 11,532 triangles in total.

Randomly generated asteroid with a resolution of 32

At a resolution of 64, you have 3,969 quads per side, or 47,628 triangles in total.

Randomly generated asteroid with a resolution of 64

At a resolution of 128, you have 16,129 quads per side, or 193,548 triangles in total.

Randomly generated asteroid with a resolution of 128

At a resolution of 256, you have 65,025 quads per side, or 780,300 triangles in total.

Randomly generated asteroid with a resolution of 256

Personally, I quite like the look of the 8 and 16 resolutions, for that low fidelity look. Here are a few other examples using a resolution of 8. The first example has the same settings as the above asteroid, but with a different random seed for the generator.

Randomly generated asteroid with a resolution of 8 using a different seed

Using a set of three separate layers of noise generation, it's possible to generate asteroids that look quite different, like the following which is at a resolution of 8 still, but with different roughness settings.

Randomly generated asteroid with a resolution of 8 using different settings

There are more things which could be done to enhance the asteroids. Of course, there's no post processing on these, but also the lighting could be improved, there could be some ambient occlusion to make the deeper recessing darker, for example. Perhaps I'll revisit this at a later date with enhance lighting.

Shaded Wireframe Script

Posted by Adam on 29 December 2021 at 12:07 pm

As I work through reacquiring the knowledge I once had, I'll be frequently posting creations and discoveries. That way, not only can I refer back, but also I'll be documenting my progress.

The first snippet is simply to enable wireframes for a camera object. Create a ShadedWireframe script, and assign it to the camera object:

using UnityEngine;

public class ShadedWireframe : MonoBehaviour
{
    [SerializeField] private bool wireframe = true;

    void OnPreRender()
    {
        if (wireframe) GL.wireframe = true;
    }

    void OnPostRender()
    {
        if (wireframe) GL.wireframe = false;
    }
}

VSCode intellisense for Unity

Posted by Adam on 29 December 2021 at 11:35 am

The first step with any project is to make sure your work area is setup and comfortable. Unfortunately, Unity doesn't always make this too easy. With it having been a few years now since I last worked on anything game dev related, everything has to be setup again, and with it, comes my first issue. Intellisense not working in Visual Studio Code for Unity.

I tried a number of things, but in the end it came down to needing to specify the location of Mono.

"omnisharp.useGlobalMono": "always",
"omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/Current"

Adding this to the settings.json file was all it took, though what a frustrating journey it was to discover that.

Second Era

Posted by Adam on 28 December 2021 at 5:55 pm

It has been a long time since I last entered the Plump Helmet Cave. The last two and a half years have seen dust settle on what was once the dream of building a rich medieval settlement simulator. Events outside the cave forced me into a new direction, yet for some time now, there has been an itch in the back of my mind, a thought that I have been unable to fully grasp, a need that I have been unable to fulfil. Life outside the cave has been prosperous, yet still, the itch remains.

In the terminal light of these dark nights, I have pondered the question of what eludes me, what thought evades my attention. And in the quiet of the winter, when everything is calm, I have contemplated the question of what I am capable of. Have I reached the apogee of my potential? Or am I still growing? What is the meaning of my life? What is the meaning of my existence?

For over twenty years I have toiled away, learning my craft, perfecting my ability to create things. Yet surely the time is soon approaching where my natural ability will begin to wane, where I will slow down, where I will be too far through the journey to start again. Perhaps that time has already passed, but perhaps it has not. I have not yet reached the point where I can no longer create things. Magical things.

And so, I have returned to the cave. I have returned to the workshop within the cave, to begin working again. And so begins, the Second Era.

Follow us

If you're interested in supporting us, please take a look at our Patreon.

And why not follow us @plumphelmetcave as well?

First Update of 2019 — Settlers

Posted by Adam on 19 April 2019 at 10:26 pm

Today was a bank holiday, but I didn't go and drink ale in the sun, no, I stayed inside like a craftsdwarf and I worked on this amazing project. It's tough, getting back into such a complex project after 8 months off it. It's daunting, the thought of getting back up to the level of proficiency that I was once at, but the only way to do that is one step at a time.

And that's what today's update is, a single step, turning artwork made many moons ago into in-game objects.

Settler Artwork Preview

Today I worked on integrating the settler sprites into the game. Behind the scenes, the settlers exist in data, but displaying them on the screen required the use of a number of textures, sprites, and sprite renderers, all positioned correctly and manipulated when the settler changed direction. The header image to this post shows a bunch of naked settlers stood about in the grass utterly confused at their brief existence, their only action to randomly turn in despair, glued to the spot, mindless.

The game, as it stands—and as you can see from the Announcing Feudalia post—is very incomplete. There has been a lot of work on the initial framework, such as the definition system (to allow modding later on), the world generation (I love this), the new game experience (my favourite is the settler screen), and the map and terrain work (which, let me just say, took a lot of work to make performant.)

What comes next is to try and get to a point where a basic playthrough can occur. This is, in my eyes, having some settlers who can build a simple shelter, who have needs such as hunger and thirst, and who can make basic produce and eat/drink etc. Once you have those basics, you can start to add things in: animals, equipment, weapons, combat, health, death etc. And, after that, you can add more, such as psychology and moods and RNG powered events and items and beliefs and magic and potions. And goblins.

The next task will be to introduce a basic AI, movement, pathfinding, etc. After that, I'll need to start having a think about how to design the structure behind these actions. How will creatures—the base class for animals, people, etc—decide what their priority is? There will need to be needs such as hunger, thirst, health, etc. There will need to be labors or jobs for settlers, but not for animals etc. But this is what is so fun. This is a problem I've never faced before, and I've been programming for 20 years now. I love it.

It feels great to be back on the project again.

Follow us

If you're interested in supporting us, or signing up to receive pre-alpha releases, take a look at our Patreon.

And why not follow us @plumphelmetcave as well?

This post is from the First Era of Plump Helmet.

This was before the great break of 2019-2021 and the predominant project of the time was Feudalia. The project was placed into cold storage and has not been revived yet. The dream remains alive however. These posts have been kept for posterity.

Newer Page 1 of 4 Older