Procgen Spaceship

By Paul Spooner Posted Thursday Jun 27, 2019

Filed under: Projects 58 comments

I mentioned in this week’s diecast (around the 18:30 mark) that I thought Rebel Galaxy would have been improvedother flaws not withstanding if it had some procedurally generated spaceships, instead of just the stock ones. If proc-gen is an unfamiliar term, Shamus has written a few articles on it. Okay, more than a few. Actually, it’s all he talks about when he has time to stop complaining about videogames, but you know how life is, what with work and family and sleep, who has time for obsessions?

So, why am I talking about proc-gen then? Well, it’s an obsession of mine as well, and a large part of what drew me to this site. I could go on about my own projects but I think we’ve done enough introduction, so instead let’s make apractically unlimited set of

procedurally generated spaceship!

The right way to start a project like this is to decide on a programming language, and some code conventions. Then you set up your development environment, and begin writing header files. No, wait, that’s not right. That’s how to… actually that’s not the right way to do anything. To design something you need a goal, not a set of processes. In this case the goal is to program the computer to be able to design and model spaceships, and that’s basically impossible if you can’t even…

Do it Yourself First

So that’s where we start. It may feel like a waste of time to start a programming project by doing the work by hand. But this feeds back into the point about code documentation and game design. Programming a computer to do design means communicating something complicated in simple terms to someone who”something that” in this case, but the principle is the same has no idea what you’re talking about. That’s hard enough when you’re an expert, but when you don’t know how to do it yourself, it becomes next to impossible.

Ok, so where do we start with spaceships? Well, I don’t know about you, but the first ingredient I want for a spaceship is:

Well, it’s not great, but I don’t have all day here.
Well, it’s not great, but I don’t have all day here.

Space!

Ahh! Mmmm! Nah! Ehh! None of that! I won’t have any; Oh! Well, you’ve gone and done it now. Yes yes, you’re very clever for, But you don’t have to, Yes, that’s how it goes but. But… But now you’re just saying “Space!” over and over!
So after we’ve blacked out the background and added some far-away stars and a close-up star or two, and a few big colored spheres for planets I think we can finally begin with the ship part of the spaceship that you’ve all been waiting for. And, like so many other things, let’s begin this design with squares. And because I prefer making 3D spaceships, let’s volumetrize that square and:

Okay, good work everyone. Pack it up and go home.
Okay, good work everyone. Pack it up and go home.

Throw Some Cubes Together

Cubes are special for being clearly artificial. Spheres appear everywhere in nature,Just look at the background! but the right angles of the square, and by extension of the cube, implies intent and planning. Cubes are, in some senses, the essential artifact.

Still though, some greebles wouldn’t hurt.

Don’t let your pareidolia get out of control now. It’s just a bunch of cubes.
Don’t let your pareidolia get out of control now. It’s just a bunch of cubes.

Now, I wouldn’t recommend stopping with the cubeStar Trek Borg vessels notwithstanding, though the overbearing simplicity of the shape grants a profound insight into the radical conformity of that fictional collective. but there’s no harm in starting there. We can make arrays of cubes, and cubes covered in cubes, and fairly soon we arrive at something that somewhat resembles a spaceship of some kind.

Kinda like a spaceship, right? I mean, it doesn’t look like anything ELSE!
Kinda like a spaceship, right? I mean, it doesn’t look like anything ELSE!

It’s missing something though, isn’t it? We have something that looks manufactured, but it might just as well be a modern building. We need another shape, one that still connotes artificiality, but also implies motion. We need the circle! And as long as we’re doing squares, or rectangles really at this point, let’s combine the principles and use:

I think I hear this spaceship driving around my neighborhood late at night.
I think I hear this spaceship driving around my neighborhood late at night.

Lathes of Rectangles

Yessir, that’s more like it. I’m feeling the spaceshippiness already.
Lathes are great because they look like wheels and turbines and rocket engines without even trying.

So now that we have our two essential elements, we should start playing with the functional sections of a spaceship. For lack of a better plan, I propose to start at the back and work forward. And what’s at the back of every spaceship?

Engines?
Engines?

Engineering

I always think of engineering as being characterized by lots of cables and tubes and pipes snaking everywhere, so let’s do that.

Oh tubes. Not, um, not engines then?
Oh tubes. Not, um, not engines then?

Maybe some of the pipes are glowing? With, I dunno, radioactive fuel? It’s a spaceship! Glowy bits!
I was sure you needed engines though.
I was sure you needed engines though.

And of course, we need some engines. Big engines! Small engines! Short ones and long ones! Engines for the engine god! That’s what an Engineer is, right?Let me have this. It’s better this way.Probably.

Right. There it is
Right. There it is

Okay, so we have the engine territory, but now we need a territory for all the people that will get thrown all over the place by the explosions from the guns that we’ll get to near the end of this article. That’s right, we need the:

Crew Quarters

Now, as fun as it would be to start procedurally generating the interior of this spaceship, and making procedurally generated bunk halls and captain’s chairs and massage parlors and such, this very temptation brings me to my second principle of design. You’ve probably heard the phrase “Don’t re-invent the wheel” which warns against redeveloping familiar technology. This one is similar, and can be phrased as, “Don’t depict the familiar” or, at least, not if you can help it. The familiar is really difficult to get right, exactly because everyone knows what it should look like. Everyone is familiar with beds and chairs and doorways, so, why bother? Instead of spending a bunch of time making things that everyone already knows about, let’s just nod to them with a bit of shorthand in the form of lit-up windows.

Hmm, okay. Not as fun as seeing the interior, but better than nothing!
Hmm, okay. Not as fun as seeing the interior, but better than nothing!

Adding windowsNope! Not doing that joke either. does two things for us. As above, it lets us imply crew quarters without actually modeling them. But just as important, it lets us indicate scale.

Are you sure this is the same ship?
Are you sure this is the same ship?

And just like that, we can turn a tiny spaceship into a huge one, all with one little parameter. Pretty neat!

Okay, we have engines and crew, now let’s add the part I was complaining about earlier. Some big empty spaces between the dangerous engines and the fenestrated quarters that we can fill full of:

Yes, okay, the spaceship is casting a giant shadow on the planet, exposing the ruse of the false perspective. Is not perfect system.
Yes, okay, the spaceship is casting a giant shadow on the planet, exposing the ruse of the false perspective. Is not perfect system.

Cargo

I think all we need for this is to make some big modular blocky parts. We can put them on the engineering section, for, storing fuel! And cargo on the crew section to store, rations I guess?

And then add something that looks like a door to themMoar rectangles!.

If that doesn’t look like a bunch of cargo bays, um, too bad?
If that doesn’t look like a bunch of cargo bays, um, too bad?

And I guess that will do it for the cargo section!

And with that, all that’s left are the:

I’ll admit, it’s a bit busy.
I’ll admit, it’s a bit busy.

Guns

Which are basically the opposite of cargo, long narrow lathes instead of short blocky cubes.
From there we can do turrets, which are just gimballed guns. We’ll add some cargo units to the guns for ammunition storage.

Man, the view from the upper decks used to be so good! Now it’s just the side of this lousy turret.
Man, the view from the upper decks used to be so good! Now it’s just the side of this lousy turret.

So, that’s the process! Obviously I could add more detail and improve the design, but that’s not the point. The point is to take the design process from start to finish and get comfortable with the steps involved.
You can download the source file for all of this, and play with it yourself. Next step is to make three or four more of these, and really solidify the process, and then, finally, we can start writing some code.

 

Footnotes:

[1] other flaws not withstanding

[2] practically unlimited set of

[3] ”something that” in this case, but the principle is the same

[4] Ahh! Mmmm! Nah! Ehh! None of that! I won’t have any; Oh! Well, you’ve gone and done it now. Yes yes, you’re very clever for, But you don’t have to, Yes, that’s how it goes but. But… But now you’re just saying “Space!” over and over!

[5] Just look at the background!

[6] Star Trek Borg vessels notwithstanding, though the overbearing simplicity of the shape grants a profound insight into the radical conformity of that fictional collective.

[7] Let me have this. It’s better this way.

[8] Probably.

[9] Nope! Not doing that joke either.

[10] Moar rectangles!



From The Archives:
 

58 thoughts on “Procgen Spaceship

  1. Crokus Younghand says:

    Paul, the links to Shamus’s articles, the Diecast and your last article are broken, the URLs have some garbage (“%E2%80%9D”) inserted in them twice.

    1. Lino says:

      I also got a white page for the source file link.

  2. Baron Tanks says:

    Paul! I don’t know what prompted the sudden creation of articles on the site (maybe Shamus’ comments about not being able to produce much content this week?) but I’m very glad to have a ‘new’ voice on the site. New goes for the written part, obviously. I couldn’t really get through your Rebel Galaxy post as it got very draggy and listy, although that might have been the point. But your written stuff here, your obvious passion and the quirky humor that you keep quite subdued on the DieCast made this a pleasure to read. It’s also a great view into design, as every step along the way I’m like, hey, I can do that. I don’t really have a greater point in all this, just to let you know and encourage you that these articles are a nice breath of fresh air and I hope you can more often fill a slot here or there. Thanks!

    1. Asdasd says:

      Two articles in and I’ve just realised how badly we, the commentariat, have collectively screwed-up in failing to begin every comment with ‘So Paul, ‘. Maybe Shamus could implement a script.

    2. Paul Spooner says:

      I’ve been glad to be able to help as well. Yes, the motivation is as you surmise. I’ve had a few open evenings this week, so it worked out. Probably won’t be able to write this much every week, but then again, there aren’t usually this many holes in the schedule.
      I’d really like to finish this series though!

  3. Philadelphus says:

    Is this a new use of the word “lathe” I’m not familiar with? To me a lathe is a machine that you turn thing on. I haven’t heard the things so-turned be called lathes before (which is what I’m gathering from context here).

    Pretty cool ship though! I’m guessing by all the sparkles (is there a technical term for those?) that you used Cycles with a short render time?

    1. William Beasley says:

      I have extensive machining experience and this usage of the word also mystifies me. Moreover, I don’t really understand what shape he is attempting to assign the word to. It would seem he is implying the layered bowl shape, but I find it quite strange.

      1. Paul Spooner says:

        Apparently it is also a 3D geometry term. I wasn’t familiar with it either, so maybe I’m using it incorrectly. If you know of a better term for “a 3D model whose vertex geometry is produced by rotating the points of a spline or other point set around a fixed axis” I’d love to hear it.

        1. William Beasley says:

          They are called solids of revolution. However, you may be better off simply referring to them in a less technical manner as most round objects are technically this. Spheres, cylinders, cones, and more complex things like toruses are technically this.

          EDIT: A solid of revolution with the profile of a rectangle is a cylinder or a compound cylinder.

          1. Decius says:

            “A solid of revolution with the profile of a rectangle is a cylinder or a compound cylinder.”

            The converse is true, but you left out “With a side of the rectangle parallel to the axis of rotation”. If you skew the rectangle from the axis you get a different solid of revolution, which I’m not sure has a special name.

            1. William Beasley says:

              True enough. Though the original point remains that such a term (even when the correct one) is vague to the point of uselessness. As it boils down to things which are round in some manner. If the intent was such just state circles or something simple to not cause any confusion. My confusion is gone now that I am pretty sure this is what he means at least.

          2. Abnaxis says:

            Can we please abbreviate them as “SORe” if we decide to go with “solid of revolution”? Then we can have a spaceship covered in sores… Maybe even “eye sores” for the ones that look like optics :-D

      2. Guest says:

        I don’t really understand what shape he is attempting to assign the word to.

        Any solid of revolution, I guess.

        P.S. Oh man, I really should refresh the page before commenting.

  4. Noah says:

    Looks like there’s no source file at the last link? I’m just getting a 404.

  5. Asdasd says:

    Getting some mild trypophobia off of those engines (if you don’t know, don’t google it!)

    1. stomponator says:

      Holy crap! I… uh… I’ll be in my bunk.

      1. Paul Spooner says:

        Mr. Cobb, your invocation confirms this may be a real spaceship after all.

  6. tmtvl says:

    If I want to turn in a screw, I could make a screwdriver, but then I’d have to make another screwdriver if I get a different type of screw. I should make a tool that lets me make screwdrivers instead. Good to see you thinking about your problem set rather than throwing code at the wall and seeing what sticks.

  7. Lars says:

    Anyone else sees a Turok gun in the picture where the tubes are lit green?

  8. Hector says:

    Professor X: “What are Starships made of?”
    Wolverine: “Tubes!”
    Professor X, with a look of disgust: “I can actually feel you trying to picture a starship.”

    1. Paul Spooner says:

      Interesting that you bring up “Starships”, which I consider to be distinct from “Spaceships” and are characterized by, well, here’s the whole article:
      http://blog.projectfledgeling.com/20180506/1148/

      1. Hector says:

        Well, it was a joke reference to a Pete Holmes video, thrown out in a muddle because it made me laugh. Sort of a good point, though. After all, what would a guest contributor need with a starship?

        (The tubes are odd but intriguing.)

  9. Dev Null says:

    The little glowing windows make it look huge. The big glowing green pipes make it look about 6 inches across. Now, given that it all works on the power of hand-waving, there is absolutely no reason why your spaceship might not need 50m diameter pipes full of glow in order to work. Still looks wrong though. Reckon I’d scale the pipes proportionally to the windows.

    1. Dan Efran says:

      I think the glowing tubes don’t look good at any scale.

      That said, HURRAY, I was just wondering when we’d ever see another procgen writeup here – Shamus doesn’t seem to code much lately. So thanks, Paul, for bringing back what I still optimistically consider the site’s main topic.

      1. Bubble181 says:

        The main topic of this page is role playing games and a comic made with stills from a movie. Obviously. There’s been some off-topic posts about computer games and programming lately, and some sound stuff, but really. It’s even in the name!

    2. BlueHorus says:

      There is absolutely no reason why your spaceship might not need 50m diameter pipes full of glow in order to work. Still looks wrong though. Reckon I’d scale the pipes proportionally to the windows.

      I’ll second this. Those massive pipes make it look like it’s made of lego. Could you program it so that the number of pipes increases, rather than the size?

      1. Mephane says:

        It would also look better if the pipes would stick tightly to the surface of the ship and not bend away from it.

    3. Karma The Alligator says:

      Not only that, but those pipes look like they scream “weak point here!”

    4. Paul Spooner says:

      Great feedback guys. Thanks very much. I’ll try some variations next time, maybe less tubes. My previous intuition was “engine room has no windows” but I figured I’d experiment with tubes and see how it looked. Agreed, experiment failed.

      Why didn’t I just fix it then? Turns out I wrote the whole article before even starting on modeling, so I really didn’t know how it was going to turn out. By the time I got to the tubes section, I wasn’t even trying to evaluate the strategy, just push through to the end. Next time I’ll try something different. Any suggestions as to what?

      1. Steve C says:

        Bundles of small tubes instead of big individual ones?

        1. DerJungerLudendorff says:

          Or at least in places that aren’t going to be the first to get hit?
          Maybe plug them into turrets and such?

      2. Oliver says:

        Strips/blocks of coloured light on the side of some of the blocks? Sort of like the lower green pipe on the “I was sure we needed engines though” image appears. It could suggest there is something else inside the ship other than living space.

      3. beleester says:

        Glowing radiator fins? Electrical arcs and prongs to suggest some sort of force field generator? Tron Lines to suggest power flow?

        1. Abnaxis says:

          Oooh, I like the idea of sticking some prongs and letting a particle system draw some lightning between them…

      4. Syal says:

        Coils. Nothing says power like a bunch of coils. Put them on the engines for instant acceleration. Put them on the guns for explosive firepower. Put them on the crew bunks for power naps.

        Coils.

        1. Baron Tanks says:

          Put them on the crew bunks for power naps.

          You slayed me. Great one sir!

          1. Philadelphus says:

            Only great self-control prevented my screen becoming covered in hot chocolate upon reading that. Kudos.

      5. Kathryn says:

        My first thought reading the title and intro was that you were going to base the rough design of the spaceship on the intended mission profile. A short-distance crew transport shuttle is going to have a very different design than a long-haul cargo vessel, and a military ship will have a very different design from either (indeed, one would expect quite a few different designs on military ships, just as an A-10 and an F-16 are very different platforms). So you would feed the procedural generator info like crew complement, intended duration of nominal flights, how much combat it expects to see, etc.

        That direction might be too different from what you had in mind, though.

        1. Paul Spooner says:

          I do have some code in development that will run a design based on requirements, it mostly just makes a bill of materials right now, but I’d like to integrate it with more visualization. So, yes, the deep design aspect is on my mind.

          Sadly, it turns out that a list of requirements, or even of materials, is not enough information to derive a full design, or even a layout. This is one of the difficulties that we run into with engineering. Often the customer has an image in mind, but they won’t tell you what they want it to look like because they think all they care about is the function. That’s why I’m starting with the 3D design, I can always fill it in with functional parts later.

  10. Karma The Alligator says:

    Ahh! Mmmm! Nah! Ehh! None of that! I won’t have any; Oh! Well, you’ve gone and done it now. Yes yes, you’re very clever for, But you don’t have to, Yes, that’s how it goes but. But… But now you’re just saying “Space!” over and over!

    Nope, just went “the final frontier”, and I really thought that’s what was in that annotation.

    1. Paul Spooner says:

      Maaan, I should have just cut it off at “you’re very clever”

  11. Jabberwok says:

    I like procgen ships in a lot of games, but I’m not sure I would’ve wanted them in Rebel Galaxy. First, because I happened to like the look of the existing ship designs. But more importantly, I feel like procgen ships might reduce a player’s ability to parse what’s happening in a fight, or to make decisions based on prior knowledge.

    For example, an experienced player might be able to look at an enemy ship and know how many broadside ports it has compared to his own, or remember that a powerful ship has weaker turrets than average, so he can safely tail the ship and focus fire on its engines. One of my personal favorite tactics was to ram ships much larger than me, because I happened to know that all of their broadside ports were concentrated towards the rear of the hull. So I could ram them near the front, then unload my own broadsides at point blank range, where they couldn’t retaliate. If all of the ships were procgen, it would be much more difficult to learn and use tactics like this. I could pause and scan every ship looking for weaknesses, but that’s not really using prior knowledge to my advantage, which is usually more satisfying to me.

    1. Paul Spooner says:

      That’s a really good point! It brings up something that I’m hoping to address in this series, which is design spec and style. A lot of times, I see people talking about proc-gen as completely random and out of control, but it doesn’t have to be that way. I’m sure it’s possible to specify a broad design style, and then allow variations within that for different size or focus. The star-destroyer wedge shape of the militia craft in Rebel Galaxy is a great example. Just because I think they could proc-gen more variety, doesn’t mean they would need to eliminate the visual style of the different faction vessels. If anything, it would be nice to have more similarity between designs from the same faction at different scales, and even across purposes.

      1. Jabberwok says:

        That is true.
        Damn, now I have to reinstall the game, and I’ll be looking more closely at the ship designs…

    2. Philadelphus says:

      It could be interesting to have a game where it procedurally generates all the ships at the start of a game, but based on design information such that different factions have their own recognizable style, as well as different ship classes all looking vaguely like we “expect” them to. You’d have plenty of time to observe them and learn their strengths and weaknesses. Then have the game very slowly introduce new ones as the game goes on, just fast enough that there’s often something new to learn about, but not so fast that everything changes overnight. Something like simulating real-world vehicle development over time.

      1. Paul Spooner says:

        Yes! I’d love to get to something like this. And, as long as the facility is in place, it would be great to be able to order your own bespoke design based on your specifications. The pirate Lords, for example, could have unique ships which would make them more interesting to encounter.

  12. ooli says:

    Damn I was sure to read a Shamus article… From when Shamus was fun and lighthearted.. like before Mass Effect 3 broke him :)

    Nice article Paul. What about Symmetry? isnt it the key ingredient for beauty

    1. Paul Spooner says:

      I’m definitely planning on using significant symmetry as you can see from this first example, which includes both mirrored (right and left) and radial (for all the round bits). I’m thinking of doing a primarily radial design next. But a bit of a-symmetry is good stuff. I’m looking at you BV 141! (also see the turrets on this ship, though I’d entertain the argument that they are the ugliest thing about it).
      Point being, yes, symmetry is a good rule, but I’m interested to see how flexible it is.

  13. Tohron says:

    Just a tip for creating images in Blender Cycles: if you use the Denoiser (find it under the RenderLayers tab (Option after the Render tab), check Denoising) it does a good job cleaning up the static in the images without consuming too much more processing power. Higher Strength and Feature Strength means more cleanup, but also more potential loss of detail.

    1. Paul Spooner says:

      Yes! I love the denoiser! Sadly, it denoises all the stars, and I didn’t have time to debug it.

  14. Grampy_bone says:

    Cool! Now just make it into an open-world (open galaxy?) procgen space pirate game like Assassin’s Creed Black Flag.

    In space.

    1. Rack says:

      Callback to Pixel City?

  15. default_ex says:

    It’s too square. Ships in sci-fi tend to have a lot of 45 degree angles. Edges are generally thin beveled with 45 degree angles. Chunks are cut off rectangles along the longest axes with a 45 degree angle “—–\_____” sorta like that. Needs to be dotted with lots and lots of access panels, raised and beveled again with 45 degree angles. The special effects industry guys that post videos on YouTube say, “ships are made of 45 degree angles” and it’s only partly a joke.

    For smoother ships. The ones we see in Star Wars prequels were primarily made by first making a rough draft out of boxy shapes from foam. Then they vacuum form plastic over it to turn those rough boxy shapes in smooth shapes. Could probably replicate that workflow with cloth simulation in proc-gen, doesn’t have to be perfect just a general cloth draping over the boxes approach to form the smooth shapes.

    A lot of the ships in movies and TV are made from kit bashing, specifically car model kits. Pop the hood on your car. Look at the alternator, imagine the pulley wasn’t there and there was instead a circle of tracer lights inside of it. Look familiar? Seen that bit in a lot of sci-fi as part of ship engines, grossly scaled up of course. Do this for a lot of car parts under the hood imagining they were diced up, you’ll find a lot of familiar things from sci-fi and the bulk of it is simple geometric shapes merged together.

    1. Paul Spooner says:

      Yeah, the “bevel” modifier does wonders for this stuff. And agreed, greebles are magic. I’m saving all that busy-work for the computer to do later though. Trying to get a feel for the large scale structure first.

  16. Abnaxis says:

    I’m pretty sure I’ve seen a while series a blog posts on proc genning ships somewhere else like 5 years ago? I’ll have to Google when I have time tonight…

    1. Paul Spooner says:

      There have been a few, yes. Haven’t seen any that dig in to the functional and stylistic aspects though, most start with a code gimmick and are done when that is exhausted.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply

Your email address will not be published. Required fields are marked *