Procgen Background

By Paul Spooner Posted Tuesday Aug 27, 2019

Filed under: Projects 45 comments

So, I’ve made quite a few space ships in this series, but none of them have received as much criticism as the background starfield.We’re not counting the tubes, okay? Okay. So that’s what I’m going to be working on today. It’s not going to turn out great, but it will be much better than it was. I mean, you can see the result in the splash image, so you can go straight to the comments if you see anything you don’t like.

The background effect was built without referenceMy first mistake? Hardly. but I had something in mind about big crosses and circles around startlingly bright stars. I think it probably came from some of the illustrations in the GURPS space source booksor the TMNT Guide to the Universe, but it was vague, and I’m lazy. So instead of improving the background until it objectively looked good, I just kept lowering my standard of what I was expecting while I was working until I thought “yeah, that looks good enough” and moved on to the spaceship making part. This is why reference is so important, at least for me. Maybe some people have enough internal artistic sense to force themselves to create a refrerence-free success, but I’m not that person.

How Do You Find an Image?

So, in order to improve this background, I needed a picture that looked pretty much like what I wanted. I needed reference. Sadly searching Google image for “Stars that look like they have exes and circles around them” doesn’t really work all that well. Even searching for “Awesome stars” mostly ends up with images of nebulas, which, okay, fair! But I’m trying to make STARships here, not NEBULAships.

Fortunately, my dad is into astronomy, and we’ve built a few telescopes together, so I know where these cross shaped visual artifacts come from. They are “diffraction spikes” off the spider that holds the secondary mirror in a reflecting telescope. Unfortunately, that didn’t really help me find the reference art I needed either. Where do the circles come from? A few people in the comments said they were lens flares, but they are exactly centered on the stars, so that doesn’t seem to make sense. Eventually I found this file https://en.wikipedia.org/wiki/File:Pleiades_large.jpg

So pretty!
So pretty!

Which seems to be pretty much what I was looking for. That’s basically what I have already though. Right?
Yeah, those basically look the same.
Yeah, those basically look the same.

So, that’s a miserable failure. Amazing what having an objective standard of excellence can do to your evaluation of your work. I guess I should do something about that.
Boom!
Boom!

How Did I Do That?

So, this is ostensibly a series of programming articles. And in order to maintain the premise, I’m going to try to explain the “source code” for this image. You can download the Blender source file here:it’s in V 2.80 now
http://jhundts.org/ProcgenSpaceship/ProcgenSpaceship7.blend
but instead of leaving it at that, here’s a screenshot of the node setup.

I like to think this looks like a spaceship.
I like to think this looks like a spaceship.

Just as an overview, each of these little boxes are “Nodes”. They have inputs on the bottom left, and outputs on the top right. If an input isn’t connected, the node uses the default value, which you can edit on the node itself. Unfortunately, it’s pretty hard to talk about anything beyond that, so here is another screenshot, re-arranged a bit, and with colors so we know what we’re all talking about. Or, you know what I’m talking about.
Colors and stuff! I said colors again!
Colors and stuff! I said colors again!

The Blue

Let’s start on the left, with the blue boxes. There’s a noise image that I’m using because I can’t figure out how to get a plain noise function in Blender, so I made one in the Gimp and baked it into the file. There’s a galaxy layer, which is a big sphere with a particle system on it to randomly distribute some simple galaxy objects. That layer gets processed with a variable size blur so that the small galaxies don’t get too blurred. I’m using the noise image to add a bit of flavor to the galaxies, as well as a bit of low level noise to the background of the whole image. There’s also a “Background” layer, which renders the stars, which are themselves a giant sphere with a couple of particle systems to randomly distribute some stars. The particle system has “clumping” turned on, so the stars aren’t quite evenly distributed. Then I just add those all together and feed it into:

The Green

Which is basically the foreground and nebula layers. In the bottom left corner is the foreground, which gets re-leveled and alpha-over masked over the stars before the flare operations, as well as put in to the pipeline further on. Pretty standard stuff.

The galaxies don't look great here, but I like the color variation they add to the background in the end.
The galaxies don't look great here, but I like the color variation they add to the background in the end.

The really special part here is in the nebula, which I noticed in the reference image was concentrated around the bright stars.
This doesn't look much like a nebula either. Maybe I can do something about that at some point.
This doesn't look much like a nebula either. Maybe I can do something about that at some point.

So I used a “clouds” texture and multiplied it by a super-blurred version of the brightest stars from:

The Purple

Which is the special rings effect section. I really did try to get a lens flare working which properly handles overlaps, but I couldn’t figure it out, so you’re stuck with this. It basically filters for the brightest stars, runs them through a “Dialate” node to make big circles, does a “Sobel” edge detect on them to make the bright ring around the outside, blurs it, and then masks it to get a hard edge around the outside. Then does that in paralell for the even brighter stars, combines them, and runs that through a “Soften” node, to take the hard edges off of the masked edges.

That's not really what I wanted. It will have to do for now though.
That's not really what I wanted. It will have to do for now though.

The “even brighter stars” are made super bright and get a fog glow filter to add that extra pop.
Fog glow is my favorite. You may have noticed I add it to everything.
Fog glow is my favorite. You may have noticed I add it to everything.

Add it All Together

That’s just about it. All of those passes get added together to result in a final image!

Why aren't there diffraction spikes on the brightest stars? Man, debugging code is difficult.
Why aren't there diffraction spikes on the brightest stars? Man, debugging code is difficult.

And just to show off the foreground, here’s the planets from the last articles. I may have modified the textures just a little.
At least the planet is perfe- Wait! What's wrong with the terminator?
At least the planet is perfe- Wait! What's wrong with the terminator?

So, that’s just about it! As pleased as I was about the background before these changes, I’m even more happy with the results after the update. Just goes to show what a difference good reference makes.

Speaking of good reference, I ran across an amazing Blender artist doing spaceship models. If you were pining for some starships, check out these!
https://www.danbrowncgi.com/projects
Perhaps, some day, I’ll get the computer making stuff like that all on its own. Some day…

 

Footnotes:

[1] We’re not counting the tubes, okay? Okay.

[2] My first mistake? Hardly.

[3] or the TMNT Guide to the Universe

[4] it’s in V 2.80 now



From The Archives:
 

45 thoughts on “Procgen Background

  1. Baron Tanks says:

    SPACE!

  2. Eagle0600 says:

    You’ve still got the problem where the rings around your stars are combining, when they should simply overlap. Compare to the reference image.

    1. Mikko Lukkarinen says:

      He mentions that in the second line of The Purple:

      I really did try to get a lens flare working which properly handles overlaps, but I couldn’t figure it out, so you’re stuck with this.

  3. eVie says:

    I seriously think you’d be better served with a bunch of plain white dots on a plain black background.

    Are we supposed to be looking at all these ships through a telescope? Why would you intentionally introduce so many artifacts into the picture? I can see the merit of introducing things like film grain or chromatic aberration to go for a specific look, but you’ve way overdone it with these diffraction patterns.

    1. Mars Women Love Bright Lights And Big Stars says:

      Eventually the background image will look like an outer-space discotheque.

      1. Paul Spooner says:

        Mars women are all well and good, but what do the Venus women like?
        Subdued white dots on a velvet black background, no doubt.

        1. CloverMan-88 says:

          This image perfectly illustrates a problem every professional graphic designer has to overcome. You found a cool thing, you learned how to do it and now you’re just trying WAY too hard to show it off. Look at the reference image- there’s maybe a dozen of those cross-shaped stars on in. On yours? More like a hundred. You can have too much of a good thing. I’ve been doing graphic design for More than a decade now, and trust me – if you turn the effect way down those stars that remain will look much, much better.

    2. Melted says:

      I mostly agree. This looks… better than the first one (I actually found the “bubbles” very puzzling and figured it was some kind of extreme stylization) but it’s very busy. In addition, having circles overlap the planet looks… distractingly wrong. I’m not saying it IS wrong; I don’t know anything about optics and maybe that’s what would happen (it seems like that might be the case?), but it looks wrong–like it’s a lens flare, or like the “stars” there are actually things that are between the planet and the camera.

      I like how the nebula looks but I don’t like the galaxies; I think they look weird.

      I don’t think it necessarily needs to be plain white dots–some color is nice and having stars of varying brightness is good, too–but I think it would look better with less stuff.

      Are we supposed to be looking at all these ships through a telescope?

      Yeah, that’s a good question.

  4. Mephane says:

    While this is a massive improvement over the old background style, it still looks very, very wrong to me. I think the entire premise of trying to make it look like it was captured with a real device (in your case: reflecting telescope) by reproducing its visual artifacts should be done, if at all, in moderation only. You have mostly* successfully reproduced the visual artifacts of a reflecting telescope, without ever stopping to ask whether you should do that in the first place. Reminds me of the massive lense flares in Mass Effect, which are also very irritating. In my opinion what a human would see should be the benchmark, not a telescope, camera etc.

    *The brightness between nearby planets illuminated by the local star is so much greater than the brightness of background stars that you would at most see a tiny number of extremely bright stars, if any at all. This is why for example you don’t see stars in the background of typical images shot on the moon or looking out of the ISS,

    1. Echo Tango says:

      The question is, how much “real-life” or “human-eyes” should we be aiming for? A real human at best, would be looking with the naked eye, through a filtered helmet visor, so you’d have very low dynamic range compared to the very bright stars and very dim planets, possibly with muted or washed-out colors, and very little flares (just from imperfections in the visor or eyes). Is this human using basic HDR like we have on contemporary smartphones? Even the example image from Wikipedia looks like it’s had the color levels adjusted, if not the color values themselves (humans can’t see most light of many stars, since it’s too low or too high wavelength). What about the zoom lens on a smartphone? Is this supposed to be a view from about spaceship, which would be using fancy futuristic cameras and sensors? Is that ship compositing all of these sensors into a single image? There’s no easy answer to making a “correct-looking” image, when it’s outside of the one planet, which our species evolved our eyeballs for.

      1. Paul Spooner says:

        Good points.
        Oh! That reminds me! I keep meaning to model those diffraction spikes you see when you’re squinting at a bright light at night, the ones that happen from the light reflecting off your eyelashes. You know, right? The ones that never show up in photographs, but that you see all the time coming from street lights and headlights of oncoming cars. Probably not a good fit for this project, or, any project really. Just one more way you can tell you’re not in the matrix.

        1. Mistwraithe says:

          You don’t think the matrix models diffraction from your eyelashes??? I think you underestimate the matrix…

    2. samuel222 says:

      Agreed. Crazy lens-flares just make it seem completely unnatural, as I don’t see them anywhere except in video games.

      To me these pictures look less like stars and more like bubbles.

  5. Sean says:

    My only observations are that you seem to have about an order of magnitude too many diffraction spikes, and they look like they are all roughly the same length and intensity regardless of the “size” of the star. In the reference image, the smaller/less intense/more distant stars have much smaller and more subtle diffraction spikes.

    But, yeah, this is pretty cool. :)

  6. Philadelphus says:

    I think the ring around the stars looks kinda like an Airy disk, but I’m not sure. Those and the diffraction spikes are also showing up in front of the foreground planet, which I don’t think would happen, but then it’s not a situation I have any real-life experience with. (Realistically, a camera wouldn’t have the dynamic range to capture both the sunlit side of the planet and the background stars…probably. Maybe the planet’s in an open cluster where there are a lot of hot, luminous stars that have all just been born close together?)

    Some generic astronomical criticism below, but I’ll first say that the image looks a lot more dynamic and more interestingly-composed than the previous one, so good work on that.

    The terminator looks fine, it’s just got a shadow of one of those suspiciously-evenly-distributed moons overlapping it. Comparable-mass objects sharing an orbit is a pretty unstable configuration, though objects can share an orbit if there’s one big one and smaller ones in its L4 and L5 Lagrange points, leading and trailing it by 60°. Saturn’s moons Dione and Tethys both have a pair of smaller Trojan moons at their Lagrange points. (Also if we’re being pedantic those moons should probably have been shredded by tidal forces long before getting that close to the planet, but they do look pretty.)

    The galaxies (I didn’t realize that’s what they were supposed to be) also look a little too uniform; usually elliptical galaxies like that have a radial distribution of light with a bright core, then a more-or-less-smoothly decreasing outskirt. Galaxies, like clouds, don’t have sharp edges. I can’t really give advice on how to tweak the nodes though, I’m afraid. (I’m looking to get back into Blender just as soon as version 2.80 makes its way to a Debian repository.)

    1. Mikko Lukkarinen says:

      Calling it now: next post will be Procgen Astrophysics.

      1. Philadelphus says:

        That would be amazing. I would love a game that procedurally generatea a set of chemical elements according to some principles, sets you as an early chemist right after someone’s come up with the idea of the Periodic Table, and then it’s all about filling out the rest of the table. Gotta discover ’em all!

    2. Decius says:

      >The terminator looks fine, it’s just got a shadow of one of those suspiciously-evenly-distributed moons overlapping it.

      The shadow of the planet is not being cast from the same light source as the shadow of the moon.

      1. Paul Spooner says:

        Examine the source file my dude! The proportions may be cartoonish, but the geometry is correct! That shadow? It’s no moon…
        It’s, um…
        Actually it’s the sun. I forgot to turn off shadow casting on that material, so the sun object, way out by the star-field sphere, is casting that shadow on to the planet. Oops!

    3. Paul Spooner says:

      I’d wager you were right about the Airy disk, except that the diffraction spikes indicate a reflecting primary. I suppose the tertiary optics might be refracting? Anyway, good catch.

      The astronomical critique is well offered and quite valid. I didn’t really set the planet/moon objects up in anything like the proper scale and orientation, so yes, what I’ve shown is all nonsense, and completely unstable. I should probably make an even closer “foreground” layer for the spaceships and other foreground elements, but it’s really fun to see the light reflected off the planets illuminating the vessel.

      Fuzzing the galaxies out a bit more is just a matter of ticking up the blur radius to taste. I wasn’t working from reference for those, and as you noticed, it shows. I’ve removed the “galaxy” objects from the latest version of the background, which seems to have made an overall improvement in the image.

      1. Philadelphus says:

        Good point about the diffraction spikes! That jogged something in my memory, and I found the catadioptric telescope, a telescope that mixes a refracting lens with a reflecting mirror. That could get you both a refractive ring (assuming that’s what that is, I’m not 100% sure) and diffraction spikes. Alternatively, even a pure reflecting telescope will have some lenses in the eyepiece used for viewing the image, though that mostly only makes sense if these images were shot with a cell phone camera held up to a telescope (which, hey, those cameras are good enough that that can work nowadays for simple images of bright objects!).

        Thanks for taking the critique in the lighthearted spirit it was intended, as an astrophysicist I don’t often get a chance to talk about what I know in these comments. :) I actually really like that version you linked! Especially the nebulae—they look really cool. I’d say tone the diffraction spikes down by maybe a third so they’re noticeable, but not blatant, and it’d be just about perfect. :)

  7. BlueBlazeSpear says:

    I think J.J. Abrams would take one look at this and blush with embarrassment. The amount of lens flare here is pornographic.

    If the goal is to make some visually interesting space scenes, then I’d say that you’ve found a certain amount of success. But that isn’t the goal, is it? The ultimate goal is to plop spaceships into this and have them be the focus of the picture, is it not? I look at this and think that if you plopped a spaceship into this, it would get washed out by the overwhelming amount of light artifacts cluttering the shot.

    I guess you’ll just have to get it to a point where you’re putting ships into these scenes to see what actually happens, but my knee-jerk reaction is that this starfield is way too busy to ultimately achieve your stated goal on this project. Programmatically, it’s interesting to explore the types of values that you can fiddle with in creating a dynamic starfield, but artistically, you want people looking at the focus of the picture – the ships – and not staring at the background. Has the focus of this project changed? I might’ve missed something here.

    1. Paul Spooner says:

      Yep, from here on out it’s just more and more gorgeous space backgrounds. There’s still quite a few matte effects left to root out. The nebulas, especially, should be converted to a texture so they aren’t stuck to the camera. Hmmm.
      Here’s the improvements I’ve made to the nebulas so far:
      http://jhundts.org/ProcgenSpaceship/pgs7_11.jpg
      Mmm, so tasty.
      Temporarily took the galaxies out. They felt out of place.

      1. Echo Tango says:

        But… When do we get back to the “procedural” part, of making infinite spaceships? ^^;

        1. Paul Spooner says:

          Working on a 3d model of the Bean-with-Bacon Megarocket. Might take the opportunity to whip up Spaceman Spiff’s iconic vessel as well.

  8. Benden says:

    In the last image, some of the stars are glowing overtop the planet (which is in the foreground). I accept all the deviations from science and compromises of intent in pursuit of art but the overlap makes it hard to believe in the image in even an artistic way. Hopefully not too tough to get the code in to clean that up!

    1. Paul Spooner says:

      It’s supposed to be that way. But yes, it would be trivial to move the alpha-over after the flare nodes. You can try it yourself. Play around and have fun with it!

      1. Echo Tango says:

        It’s supposed to be that way, because the flares and glows are from the observer/telescope, not interstellar dust interfering with the light before it gets too the observer, right?

        1. Paul Spooner says:

          Correct! (though “gets too the” should be “gets to the”)

  9. Max says:

    I think what really bothers me about this is all the rectangles. In case anyone else doesn’t notice it, what I mean is that the diffraction spikes of the brighter stars often overlap and a group of four stars can act as four corners of a rectangle, or sometimes 2 stars close together can form rectangles as well. It looks unnatural, and its made worse just by how frequently it occurs. I’ve never seen a picture of space where I immediately noticed so many rectangles. In the reference image you posted it is actually possible to find a few cases of this but it’s far less frequent and far less distracting.

    1. Paul Spooner says:

      Ooh! That’s a really neat idea. Generate a bunch of rectangular starships that fit in to the diffraction spike divisions? I like it.

  10. Decius says:

    If the goal was to make a poor background procedurally, sure. But if you wanted to make a background for a procedurally generated starship thing, just take the Hubble Deep Field image and crop it down to a reasonable size.

    1. Paul Spooner says:

      Well, I’d like to be able to make animations of these at some point, and a static background just won’t work for that.

  11. Jabberwok says:

    No hyphen or hyphen? :'(

    1. Paul Spooner says:

      I’m-sorry. I’ve failed-you. I’ve failed-you-all.

      1. Jabberwok says:

        If I didn’t know better, I’d say you’ve been trolling since at least the second entry…

        1. D-Frame says:

          How do you know better?

          1. Jabberwok says:

            good question

  12. RobS says:

    I think you might be missing the real problem.

    If, when presenting pictures of spaceships, people critique the background starfield and seem to mostly ignore the spaceships, the problem isn’t that your starfield is bad, it’s that your spaceships are bland and uninteresting.

  13. Topher Corbett says:

    Turn off the rings and the galaxies, and lower the amount of diffraction spikes. I think the main issue that people are having is that it looks too busy and distracting.

  14. Aanok says:

    You mention you had trouble with lens flare, have you tried a bokeh effect?

    1. Paul Spooner says:

      Ahah! Yes! That’s the effect I was looking for!

      1. Paul Spooner says:

        Here’s what I ended up with. Source file is in the same folder.
        Also doing some crazy stuff with scaling the image up and down. Unfortunately, I haven’t figured out how to get Blender to ignore the rest of the blanks on the side of the image, but at least it saves on the really large radius Bokeh operations.

        1. Aanok says:

          Oh boy, that’s pretty trippy. I dig it! :D

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 to Aanok Cancel reply

Your email address will not be published.