{"id":47861,"date":"2019-08-27T06:00:51","date_gmt":"2019-08-27T10:00:51","guid":{"rendered":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47861"},"modified":"2019-09-25T17:08:57","modified_gmt":"2019-09-25T21:08:57","slug":"procgen-background","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47861","title":{"rendered":"Procgen Background"},"content":{"rendered":"<p>So, I&#8217;ve made quite a few space ships in this series, but none of them have received as much criticism as the background starfield.<span class='snote' title='1'>We&#8217;re not counting the tubes, okay? Okay.<\/span> So that&#8217;s what I&#8217;m going to be working on today. It&#8217;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&#8217;t like.<\/p>\n<p>The background effect was built without reference<span class='snote' title='2'>My first mistake? Hardly.<\/span> 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 books<span class='snote' title='3'>or the TMNT Guide to the Universe<\/span>, but it was vague, and I&#8217;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 &#8220;yeah, that looks good enough&#8221; 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&#8217;m not that person.<!--more--><\/p>\n<h3>How Do You Find an Image?<\/h3>\n<p>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 &#8220;Stars that look like they have exes and circles around them&#8221; doesn&#8217;t really work all that well. Even searching for &#8220;Awesome stars&#8221; mostly ends up with images of nebulas, which, okay, fair! But I&#8217;m trying to make STARships here, not NEBULAships.<\/p>\n<p>Fortunately, my dad is into astronomy, and we&#8217;ve built a few telescopes together, so I know where these cross shaped visual artifacts come from. They are &#8220;diffraction spikes&#8221; off the spider that holds the secondary mirror in a reflecting telescope. Unfortunately, that didn&#8217;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&#8217;t seem to make sense. Eventually I found this file https:\/\/en.wikipedia.org\/wiki\/File:Pleiades_large.jpg<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_10.jpg' width=100% alt='So pretty!' title='So pretty!'\/><\/div><div class='mouseover-alt'>So pretty!<\/div><br \/>\nWhich seems to be pretty much what I was looking for. That&#8217;s basically what I have already though. Right?<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_00.jpg' width=100% alt='Yeah, those basically look the same.' title='Yeah, those basically look the same.'\/><\/div><div class='mouseover-alt'>Yeah, those basically look the same.<\/div><br \/>\nSo, that&#8217;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.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_01.jpg' width=100% alt='Boom!' title='Boom!'\/><\/div><div class='mouseover-alt'>Boom!<\/div><\/p>\n<h3>How Did I Do That?<\/h3>\n<p>So, this is ostensibly a series of programming articles. And in order to maintain the premise, I&#8217;m going to try to explain the &#8220;source code&#8221; for this image. You can download the Blender source file here:<span class='snote' title='4'>it&#8217;s in V 2.80 now<\/span><br \/>\n<a href=\"http:\/\/jhundts.org\/ProcgenSpaceship\/ProcgenSpaceship7.blend\">http:\/\/jhundts.org\/ProcgenSpaceship\/ProcgenSpaceship7.blend<\/a><br \/>\nbut instead of leaving it at that, here&#8217;s a screenshot of the node setup.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_02.jpg' width=100% alt='I like to think this looks like a spaceship.' title='I like to think this looks like a spaceship.'\/><\/div><div class='mouseover-alt'>I like to think this looks like a spaceship.<\/div><br \/>\nJust as an overview, each of these little boxes are &#8220;Nodes&#8221;. They have inputs on the bottom left, and outputs on the top right. If an input isn&#8217;t connected, the node uses the default value, which you can edit on the node itself. Unfortunately, it&#8217;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&#8217;re all talking about. Or, you know what I&#8217;m talking about.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_09.jpg' width=100% alt='Colors and stuff! I said colors again!' title='Colors and stuff! I said colors again!'\/><\/div><div class='mouseover-alt'>Colors and stuff! I said colors again!<\/div><\/p>\n<h3>The Blue<\/h3>\n<p>Let&#8217;s start on the left, with the blue boxes. There&#8217;s a noise image that I&#8217;m using because I can&#8217;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&#8217;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&#8217;t get too blurred. I&#8217;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&#8217;s also a &#8220;Background&#8221; 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 &#8220;clumping&#8221; turned on, so the stars aren&#8217;t quite evenly distributed. Then I just add those all together and feed it into:<\/p>\n<h3>The Green<\/h3>\n<p>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.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_06.jpg' width=100% alt='The galaxies don&apos;t look great here, but I like the color variation they add to the background in the end.' title='The galaxies don&apos;t look great here, but I like the color variation they add to the background in the end.'\/><\/div><div class='mouseover-alt'>The galaxies don&apos;t look great here, but I like the color variation they add to the background in the end.<\/div><br \/>\nThe really special part here is in the nebula, which I noticed in the reference image was concentrated around the bright stars.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_05.jpg' width=100% alt='This doesn&apos;t look much like a nebula either. Maybe I can do something about that at some point.' title='This doesn&apos;t look much like a nebula either. Maybe I can do something about that at some point.'\/><\/div><div class='mouseover-alt'>This doesn&apos;t look much like a nebula either. Maybe I can do something about that at some point.<\/div><br \/>\nSo I used a &#8220;clouds&#8221; texture and multiplied it by a super-blurred version of the brightest stars from:<\/p>\n<h3>The Purple<\/h3>\n<p>Which is the special rings effect section. I really did try to get a lens flare working which properly handles overlaps, but I couldn&#8217;t figure it out, so you&#8217;re stuck with this. It basically filters for the brightest stars, runs them through a &#8220;Dialate&#8221; node to make big circles, does a &#8220;Sobel&#8221; 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 &#8220;Soften&#8221; node, to take the hard edges off of the masked edges.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_07.jpg' width=100% alt='That&apos;s not really what I wanted. It will have to do for now though.' title='That&apos;s not really what I wanted. It will have to do for now though.'\/><\/div><div class='mouseover-alt'>That&apos;s not really what I wanted. It will have to do for now though.<\/div><br \/>\nThe &#8220;even brighter stars&#8221; are made super bright and get a fog glow filter to add that extra pop.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_08.jpg' width=100% alt='Fog glow is my favorite. You may have noticed I add it to everything.' title='Fog glow is my favorite. You may have noticed I add it to everything.'\/><\/div><div class='mouseover-alt'>Fog glow is my favorite. You may have noticed I add it to everything.<\/div><\/p>\n<h3>Add it All Together<\/h3>\n<p>That&#8217;s just about it. All of those passes get added together to result in a final image!<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_04.jpg' width=100% alt='Why aren&apos;t there diffraction spikes on the brightest stars? Man, debugging code is difficult.' title='Why aren&apos;t there diffraction spikes on the brightest stars? Man, debugging code is difficult.'\/><\/div><div class='mouseover-alt'>Why aren&apos;t there diffraction spikes on the brightest stars? Man, debugging code is difficult.<\/div><br \/>\nAnd just to show off the foreground, here&#8217;s the planets from the last articles. I may have modified the textures just a little.<br \/>\n<div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pgs7_03.jpg' width=100% alt='At least the planet is perfe- Wait! What&apos;s wrong with the terminator?' title='At least the planet is perfe- Wait! What&apos;s wrong with the terminator?'\/><\/div><div class='mouseover-alt'>At least the planet is perfe- Wait! What&apos;s wrong with the terminator?<\/div><br \/>\nSo, that&#8217;s just about it! As pleased as I was about the background before these changes, I&#8217;m even more happy with the results after the update. Just goes to show what a difference good reference makes.<\/p>\n<p>Speaking of good reference, I ran across an amazing Blender artist doing spaceship models. If you were pining for some starships, check out these!<br \/>\n<a href=\"https:\/\/www.danbrowncgi.com\/projects\">https:\/\/www.danbrowncgi.com\/projects<\/a><br \/>\nPerhaps, some day, I&#8217;ll get the computer making stuff like that all on its own. Some day&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I&#8217;ve made quite a few space ships in this series, but none of them have received as much criticism as the background starfield.We&#8217;re not counting the tubes, okay? Okay. So that&#8217;s what I&#8217;m going to be working on today. It&#8217;s not going to turn out great, but it will be much better than it [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-47861","post","type-post","status-publish","format-standard","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47861"}],"version-history":[{"count":3,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47861\/revisions"}],"predecessor-version":[{"id":47867,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47861\/revisions\/47867"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}