Skip to content

Starfields and Nebulae Part 2

baeldin edited this page Apr 14, 2022 · 21 revisions

Starfields and Nebula - Part 2

Quick Note on Angle Preservation and Conformality

I will occasionally mention that a certain action will make a transform non-conformal or break angle-preservation. You don’t have to worry too much about the math behind this, what it means is that shapes are distorted by such transforms, i.e., stretched, squished, or skewed. When the effect is subtle, it can add nice filament-like structures to a nebula. However, as soon as you add stars, it will also stretch, squish, or skew your stars, resulting in oval or even long bent “stars”, which look very unnatural. Feel free to use this effect, if you like it, I mostly mention it so that when it happens and you want to get rid of you, you will know what to look for in your parameters.

The Basic Building Blocks

We’ll start with the basic loop from last time, but before we jump into it, I’d like to point out something that some of you might have already noticed: the loop in the last tutorial was a bit more complicated than it needed to be. The bread and butter of any nebula are Affine and Spherical. he left shows the loop from the last tutorial. Since both Sphericals did the exact same thing last time, we could have used just one. However, this isn’t necessarily always true, so think of the right one as an extremely basic version, while the left side is a bit more versatile and will form the backbone of almost any loop that you will be using for star fields and nebulae.

Two Sphericals One Spherical

With version 1.2 of IFSRenderer, a new parameter is introduced to Spherical: the Radius. A Spherical is just an inversion of the entire 3D space with respect to a sphere if the Offset = 0. A point that is 0.5 unit lengths from the origin will be moved to 2 unit lengths away with the same direction, i.e. the signs and ratios for the three spatial coordinates will remain the same. The smaller the radius, the smaller the sphere used for inverting, and the farther apart the transform will spread whatever is given to it. As a rule of thumb, a smaller radius will generate more diffuse structures, a larger radius will generate smaller and sharper structures.

Some Common Pitfalls

As a rule of thumb, making a nebula using Affines and Sphericals is about balancing the parameters of the different nodes to achieve a look that you like. Here are some pitfalls that can be avoided, because they can lead to dead ends where nothing you tweak will make it look quite right again. Here’s a list of things that can go wrong:

  • High values (much larger than 1) in the Translate portion of Affines can make it difficult to balance the rest of the nebula, especially when most other values are small.
  • Choosing different values for the Scale portion of Affines (for example 1, 1, 2) will start distorting the nebula and make the Affine non-conformal.
  • Adding large (more than about 20 degrees) to all three angles of the Rotate portion of an Affine can make it impossible to get any kind of filaments in the nebula and result in a dotty and a bit unnatural look. Though this can vary greatly depending on your exact parameters. It’s always good to start with only one or two angles.
  • Picking a very small radius for a Spherical can make the nebula extremely diffuse and devoid of any structure.
  • Picking a very large radius for a Spherical can cause the nebula to decay into small dots or copies of the entire thing.
  • Setting the Offset of a Spherical to anything other than zero will add distortion and make it non-conformal.
  • Any nebula that is also used to generate stars will cause elongated and even bent stars if any of the used transforms is non-conformal

Recreating the Basic Flame

Set the following values in the main window:

  1. On the left side, set your Field of View = 30
  2. On the right side, set the image size to 1000 x 1000, then click Preview
  3. Set Warmup = 70 Then open the editor and create the loop shown on the upper right image. Do not touch any values for the Spherical yet, the values for the two Affines are (it doesn’t matter which is which):
Translate Scale Rotate
Affine1 1.2 0.2 0.6 1 1 1 0 60 60
Affine2 -1 0.4 0.6 2 2 2 60 60 0

Now let’s start playing around and explore the effect of the parameters.

#Useful Parameters and their Effects Let’s start with the radius of the Spherical. A smaller value for the Radius will cause the nebula to become increasingly diffuse, a larger value will make it sharper. You can easily shift the value into ranges where it won’t look like a nebula anymore. As a rule of thumb, you want visible structure but not obvious repetition. Keep in mind that the result is basically a fractal, so you can get stuff like spikes from repeating increasingly smaller shapes or spirals that look unnatural. Of course, feel free to use them anyway if you like the look!

Radius = 0.9 Radius = 1 Radius = 1.1
Radius = 0.5 Radius = 0.1 Radius = -0.2
Radius = -0.5

The image above shows an example for how the radius will influence the look of your nebula. The top three panels are probably the most interesting ones, and somewhere around Radius = 1 will be the best range. Values around 0.1 – 0.5 will not add interesting nebula elements, but together with a transform that generates stars, they can be used to generate a more uniform star field around the nebula, if desired. Now let’s have a look at the Offset parameter. This will make it non-conformal and add distortion! For the following images, the Radius = 1.

Offset = 0.01 Offset = 0.025 Offset = 0.05
Offset = -0.01 Offset = -0.025 Offset = -0.05

As you can see, the nebula is very sensitive to changes in Offset, and even small values will quickly distort it beyond looking like a natural nebula. It can be a neat trick to add a bit of structure, especially if the nebula is diffuse. Play around yourself to see the combined effects. Another simple trick to change the characteristic of a nebula is connecting nodes to themselves. This is done by right clicking and it will add an arrow looping back to the same node. For Sphericals, this will often make the nebula more diffuse, it’s a useful way to quickly get rid of unwanted structure. Of course, this can also be done on the Affines, which will often add structure. Or you can add connections between different nodes. Just play around to see what works, the effects aren’t always straightforward. If the effect is too extreme, click the arrow and adjust its weight to see if it looks nice with a lower weight.

Initial Nebula with Radius = 1 Connect Spherical to itself
Self loop with Radius = 1 Self loop with Radius = -0.5

The neat property of this trick is that while it changes the overall sharpness of the nebula, it often doesn’t affect its larger structure much, so you can modify sharpness “in-place” instead of having it shift back and forth like changing the Radius or any parameters of the Affines will often do. Play with the weight of the arrow to explore different degrees of this effect.

Multiple Sphericals

On the right side, you can see an example of a loop that uses two different Sphericals. This allows to set a different Radius and Offset for each of the two, giving a bit more control over the look of your nebula.

R1 = 1, R2 = 1 R1 = 1.15, R2 = 1
R1 = 1, R2 = 1.4 R1 = 1.15, R2 = 1.4

This shows that it can be worth exploring a few combinations! Now that we have a basic idea of what the radius can do, we can duplicate our loop to overlay a slightly modified copy. We also combine what he learned until now. We pick the lower right panel of the last examples (R1 = 1.15, R2 = 1.4) and right click Spherical 2, which is a bit too structured, and make it loop into itself. Your loop should now look like this.

R1 = 1, R2 = 1, Sp 2 -> Sp 2 Corresponding Loop

Now let’s duplicate the entire loop, either by selecting each node and pressing Ctrl + D or by clicking the little round icon with the two sheets of paper on them, as shown in the right panel. Do this carefully and pull each separated node out of the initial loop so you don’t lose track. This part is a bit finnicky. Once done, separate the two loops by removing all connections between them. You can right click drag & drop between two nodes to add/remove a connection or set the arrow’s weight to zero. I took the time to rename each node to clearly separate the loops. Once done, it should look like this:

Note that duplicating nodes splits their overall Base Weight in half, so each of these now has Base Weight = 0.5. This is fine with two loops because they have equal weight, but we must keep it in mind in case we want to add a third one, so the weights remain balanced, because duplicating one of these loops again would generate two new loops with weights of 0.25 while the other would retain weights of 0.5! For the second loop, we set R1 = 1, R2 = 0.5 and add another self-loop to the Spherical 1 of Loop B to get a nice and fuzzy cloud around or initial nebula.

We now go through all nodes and set their Base Weight = 1 and Start Weight = 0. Leave only Affine A1 and Affine B1 at Start Weight = 1. This has no effect on the appearance right now, but it will make it much easier to control the visibility of each individual loop later down the line, because we won’t have to adjust the Start Weight of all the nodes individually. Here’s what it should look like once you arrive at this step:

It’s still kind of dark and off-center, but that’s something we will deal with later. I haven’t moved the camera around at all yet so everyone can follow the tutorial and arrive at the exact same image I am showing

Adding Stars

Last time I already showed how to add stars using a simple Gaussian Blur node connected to one of the Sphericals. This works fine for the most part, but there are some additional tricks to learn and some possible problems to avoid. Also, Sphere is a possible alternative to Gaussian Blur that gives the stars a different look. This won’t matter for most of them because they become tiny dots, but it will affect the bigger ones. Now click on Spherical 2B, then add a Gaussian Blur, and then an Affine. Connect the Affine back to Spherical 2B and the remove the reverse connection to make it a one-way loop from Sp2B -> Gaussian -> Affine -> Sp2B. Set the Start Weight of the Gaussian and new Affine to 0 and their Opacity to 0 (this can be done by adjusting the value or by clicking on the eye icon). Finally, change the Gaussian’s Base Weight to a low value, like 0.01 and its Radius to 0.003. Your loop should now look like the image on the left. We want to play around with the stars a little bit, so let’s hide the other loop. Just go back to Spherical 1A and set the Start Weight to zero for now. The four images below show how the weight of the Gaussian Blur node affects the look of the nebula generated by the loop. A value of 0 will skip the star part and show the loop. Very low values like 0.01 will leave the nebula mostly unaffected and only show only a few stars.

Gaussian Base Weight = 0.01 Gaussian Base Weight = 0.06
Gaussian Base Weight = 0.25 Gaussian Base Weight = 1

As the Base Weight of the Gaussian Blur increases the nebula slowly turns into stars. A loop can be turned into a pure star field this way if the nebula element is unwanted. As a rule of thumb:

  • Gaussian weight around 0.01 -> few stars, visible nebula
  • Gaussian weight around 0.05 – 0.1 -> more stars, visible nebula
  • Gaussian weight around 0.25 -> weak nebula, many stars
  • Gaussian weight around 1 -> almost no nebula, many stars
  • Gaussian weight >> 1 -> fewer stars, no nebula Play with the values as you see fit. This changes the stars and nebula visibilities at the same time. Don’t forget, if you want to change the stars and nebula of the same loop independently, you can always duplicate the loop and adjust the weights as needed! Note that you can also adjust the weight of the Arrow between Spherical and Gaussian instead, this is useful if you want to use the same Gaussian – Affine combo for multiple loops. You can also connect your Star Affine back to an Affine instead of a Spherical, sometimes this can help solve a precision glitch.

Star Glitches

If the brightness is turned up high enough, and it often will be with nebulae, a spurious grid of stars will start appearing in the background, especially for small stars. To illustrate the problem, I set Brightness = 50:

Spurious lines of stars Fog Effect = 0.01

You can set a very small amount of Fog Effect in the main window to get rid of the artifacts without moving the stars around. Another kind of glitch is a result of a lack of precision. When rendering at high resolutions or if a star is relatively close to the camera, a tiny grid of dots will appear on its inside. This happens due to rounding errors in the single precision calculations. The root of the problem is that the Gaussian Blur is always placed at the origin and each Spherical transform inverts it far toward infinity. The solution is to move the Gaussian star away from the center before it enters a Spherical, and that can be done by feeding it into an Affine first. Either make your own Star Affine as shown in the loop above or connect the Gaussian directly to one or more of the Affines in your main loop or do both and end up with more stars! You might have to adjust the size of your stars after changing this.

Star subloop leading back to Spherical Star subloop leading back to Affine or setting Translate to non-zero on the Stars Affine

Now that we got our stars, let’s play around a bit more! The little Affine we added allows us to vary the star field. When connected to a Spherical, setting translate not equal zero will cause each star to split up into multiple stars and move them around. Setting for instance the x component to 2.5 will just result in a completely different distribution of the stars. Very small values will result in visibly similar clusters of stars. Very high values, on the other hand, will cause the stars to look tiny and group them. This can be used to get a more patchy starfield by compensating the size by increasing the radius.

Original Gaussian 0.06 Affine Translate to 2.5, 0, 0
Affine translate to 25, 0, 0 Gaussian Weight = 1, Gaussian Radius = 0.15

Another nice trick is to duplicate the Star Affine and change the scaling, for instance to 0.1, 2.5, 0.1, this will result in small rays emanating from the stars. However, they are oriented differently for each star, which kind of fails to emulate the look of overflowing image sensors or bending effects that sometimes occur in astrophotography. Below is an example of the look that can be achieved with the above numbers. The effect is subtle but changes the appearance quite a bit. You can do this on the stars of one loop but not the others.

Duplicate the Star Affine Star Affine Rays values for Translate set to (2.5, 0, 0)

Now color it and navigate to a nice viewpoint!

While I have a basic understanding of how coloring works, it’s often impossible to tell in advance how color index and color speed impact the final look, I mostly drag values around until it looks good. And so can you! Here are four versions of the above nebula with slightly varying colors and parameters, but all using the same camera settings:

Coloring Your Nebula However, there are a few tricks you can use that will make coloring easier. For this, it’s important to understand the basics of how coloring works in fractal flames. Each node has a Color Index and a Color Weight. Color Index: determines toward which color the node shifts the dots it generates. If a node is connected to itself and the dot uses it multiple times in a row, the color it draws will approach the color of the chosen Color Index. Different nodes can work against each other, resulting in none of the color indices ever being reached. You might pick a narrow band of a certain color in your gradient and never see it being picked. Color Speed: determines how far an iteration shifts the color. A Color Speed of 1 will always force each dot to be drawn at the exact color for the chosen Color Index. Values higher then 1 will cause an overshoot, values lower than 0 will push the value away instead. Values >> 1 or << -1 will cause the value to quickly jump all over the gradient, which can result in very chaotic behavior. Unless at least two nodes with differing color indices have a color speed not equal to zero, your entire flame will have only one color (Assuming you are not using delta coloring, which I will not go into here).

Coloring Example

For this illustration, I am using the Hero gradient from the boxtail_pack_04_mineshack gradient pack. Nebulae and star fields work best if there aren’t any dark colors in your gradient, because those tend to cause dark stars which look weird, but if you like that, then go for it. A great trick is to just select a node, then grab its opacity and start wiggling your mouse left and right. This will quickly change the Opacity between -1 and 1, resulting in part of your flame blinking. This is a great way of figuring out which node is responsible for which part of your nebula, not only for coloring but also later when balancing the opacity to remove overly bright areas.

Default Spherical 2 Opacity = -1

Here you see an example with All Opacities = 1 (left) and one node set to -1 (right). Next, set its Opacity back to 1 to make sure it’s visible, set its color speed to 1 and pick a color, I chose the dark red stripe at Color Index = 0.596. This makes the entire nebula red, so we need to adjust more nodes. Take Spherical 1, set Color speed = 1 and Color Index = 0.26, which is a nice blue. Then take Spherical 3 and set its Color Speed = 1 and Color Index = 0.041.

Sherical 1:
Color Speed = 1
Color Index = 0.26
Spherical 3:
Color Speed = 1
Color Index = 0.041

You can see the effect, and you can now also identify which Spherical is responsible for which part of your nebula. You can do the same for your Affines too, of course, but you get the idea. This is already pretty nice, but we want the colors to flow into each other more naturally, so we start to slowly decrease the color speeds. The red part will need a relatively high color speed to force color into the narrow red stripe, whereas the others can be moved a bit more freely. Then increase Gamma and Brightness a bit.

Lower Color Speeds Brightness = 70, Gamma = 0.35, Vibrancy = 0.15
| | Spherical 1|Spherical 2|Spherical 3| :-----:|:-----:|:-----:|:-----: Color Index| 0.26| 0.596| 0.041| Color Speed| 0.97| 0.98| 0.419|
Clone this wiki locally