Several years ago at a previous job I was fortunate enough to have people from Allegorithmic come over and demo their Substance Designer. While a couple of the other projects had definite uses for a tool like that unfortunately the one I was working on at the time we were using pre-rendered assets. Making it pretty much the worst fit for procedural texture generation. Since then however I’ve always wanted to have a good use for them since any tool that saves artists so much time is a good tool indeed.
In Astrobase we early on, in order to keep flexibility up and file size down, decided to attempt using procedural textures. More specifically to use Substances, since they have both support in Unity3d and affordable tools (available on steam). This has worked out very well so far and since that means I’ve spent a bit of time using the tools I figured I’ll make a short tutorial on how to actually make something useful with Substance Designer.
The current setup for the skybox substance in Astrobase Command.
Introduction to Procedural Textures
A procedural texture is a texture created by the computer with rules (procedures) you set up specifically for it. This means instead of the artist having to hand paint everything the computer will create it for them. These rules that the artist sets up are pretty much just references to commands that the runtime library knows, so the size of the resulting file is lower by several orders of magnitude.
You can if you want use bitmaps as elements in the node graph. This, depending on how big and many the bitmaps are, will of course increase the file size while improving the control over the visuals for the artist. In this quick tutorial we will not be using bitmaps.
Allegorithmic also has a tool called Substance Painter that creates the same type of file but is geared towards creating unique textures, for example for a single vehicle or character at a time. This will not be using that since a star field is typical of a tiling texture.
Additionally the substance can output maps for normal, height, specular and so on. Here we will only output a single diffuse map that will be used in an unlit material.
Starting Out
In this tutorial I will be using Substance Designer 4.4.1.
Create a new substance. In the substance create a new graph with these settings.
For our purposes right now, a star is a pixel in size. So we want to create a random pattern of pixels. To do this we create a White Noise node.
Getting Into It
As you can see, the detail level is at the right scale (single pixel noise) but there are just way too many stars.
To counteract this we subtract additional instances of white noise from the original using blend nodes. It’s important to remember to set these instances to different random seeds or they will be identical to the first Instance and hence not really have the effect you want.
Its getting there, but Its very uniform at this point. Lets add some more, and bigger, variations by adding some more noise. In this case a BnW Spots 1. And subtract that with another blend node.
Finishing Touches
Thats got a pretty good feel to it. A nice density with a bit of variation. However if you were to look at a photograph of the stars in reality you’d see some appearing a lot brighter (and bigger) than the others. In order to achieve this we run the star field through a Levels Histogram, isolating the very brightest stars we have. Then we blur them slightly in order to make them bigger. This however makes them less bright, to compensate for that we blend them together (Add) to themselves a couple of times to make sure they are appropriately bright. The result is then blended (Add) back into the main image.
Much better! But it seems like they are ignoring the BnW Spots node completely making them ignore local brightness, lets fix this by using the BnW Spots as a mask for the new bright stars. However Since we don’t want to lose too much brightness, first run it through a Levels Histogram to make sure we get some extra control.
Now we’re talking. But there’s something missing isn’t there? It feels a bit dull to look at. Oh thats right! It needs some color. Since we want the stars to have individual color we add another White Noise node which we pass through a Gradient Map node to map a color gradient to the brightness of the noise. This is then blended into the image using a color blend node.
Results
Its nothing groundbreaking but it gives a good enough star field that tiles perfectly. Additionally it can be generated at random seeds at the press of a button with the result being something like this.
Conclusion
And there we are. Perhaps a bit technical, but thats how procedural textures are. I didn’t get into creating nebulae for two reasons, to begin with thats a lot more involved than getting a star field looking nice. The second reason is because I’m still working on getting it just right for us and the current version is just not at a good enough level yet.