[Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Want to increase or share your knowledge? Do it here.
Post Reply
User avatar
keltwookie
Site Admin
Posts: 134
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

[Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Post by keltwookie » Wed Nov 22, 2017 2:46 pm

Disclaimer:

These series of tutorials does not claim at all to be the ultimate solution and are based on my own experiments during the development of the project. So are annotated there reflections and remarks for which I am solely responsible.If they were inappropriate and/or wrong, in this case, do not hesitate to contact me via pm for corrections or comment under this article, but, please, do not forget to mention the source of your information.
To be honnest, these articles was firstly for my own use as reminder for the whole process. It is so more a synthesis of methods and references than a real tutorial, methods and references that are, the most of the time, adaptations of video tutorials I found on YouTube. In no cases I pretend be the author of these video tutorials, the involved authors are always credited and the needed links added.

Requirements:
  • Blender 2.7x
  • … Well, a basic knowledge of the Blender interface: How to select and move objects, remove them, save, load, etc...
  • And by the way:

Code: Select all

<troll mode>Be sure running an OS which rocks and does not disable the keyboard once the latest update installed, make not freeze your screen(s), or which does not rot your system with junk and sh*twares of all sorts.</troll mode>
But why procedural?

A few explanations:


Yes, the classical method was: Seams marking on the model -> UV mapping -> texture drawing -> texture mapping -> rendering -> ...this-is-not-good-we-start-over ... Neeext !
well, even if the process is relatively easy with Blender, it remains awfull, an opinion I share with the most part of modelers whose I'v read the topics.
Concerning procedural, it is another story. First, keep in mind that the most part of modern game engines, if not all, propose it, and concerning studios themselves, they seems use it more and more. Certainly by simplification of the process at first, but also for a possible saving of loading times, as well for the artist(s) as for future possible players (briefly explained here). Regarding Blender itself: We have the chance to get a direct result on the screen via the renderings. Yes, by this method, you can see in real time the modification of each parameter, which is already in itself a considerable saving of time!
We will take this opportunity to talk about the rendering settings with this video by Andrew Price (at Blender Guru) I recommend it:

https://www.youtube.com/watch?v=8gSyEpt4-60

All of this to say that finally, with a bit of imagination, and (lot of) work, we can easily imaginate texturing about anything without any use of picture.

Part 1

We will start by creating a star, which will be the central axis of a future animation simulating orbits.

Note: This section is an adaptation from a video tutorial realized by Sardi Pax. The difference is that in the present tutorial, and for reasons of brevity and subject (the procedural textures), the part concerning the particle system will not be mentioned. Furthermore, the compositing part into the video won't fit for a whole scene, and I simplified it a lot in the current tut.
For the whole thing, please check here:


https://www.youtube.com/watch?v=XWEuFoBZO3Q

Sardi's YouTube channel
  • Open Blender
  • Enable Cycles render on the top bar, instead of the internal one. The old Blender render won't be used anymore in future versions
  • Let's begin by setting the main view and let's face the thing: → On numeric keypad, hit « 1 »
  • Then remove the base cube : Hit « x », then validate (mouse left click or « Enter »... just in case)
► Show Spoiler
  • Create a base mesh: Here, an Ico Sphere -> Shift + A :
► Show Spoiler
  • 1. In the panel at the bottom left, set the subdivisions to 6, validate
  • 2. Then smooth your mesh :
► Show Spoiler
► Show Spoiler
But why an Ico Sphere instead of an UV Sphere?
Extract from an answer from Dave Jarvis on Blender Stack Exchange:


UV spheres are best used in situations where you require a very smooth, symmetrical surface (the more subdivisions the better). However, they do relatively poorly when realistic topology is your key goal. UV spheres are not the best for organic natural shapes, because of their symmetry and the use of quads.

ICO spheres are best used for objects such as:

Geodesic Domes
Planets with realistic terrain
Rough surfaces, such as golf balls.
Source: https://blender.stackexchange.com/quest ... -icosphere

Copy that. But even if a star is not a planet, we maybe would want simulate, later, some reliefs such than solar spots or explosions on its surface (non developed in this tut). So let's go for Ico Sphere.
  • Create the base texture :
  • 1. Select your mesh.
  • 2. Select the materials tab, create a new one, then rename it (here: yellow.sun.mat). By the way, rename also your mesh (Yellow Sun here)
► Show Spoiler
► Show Spoiler
Why this name? Choosing a resource name is not as trivial as it sounds: All artists, and game developers say it and repeat it: Reuse your materials to save system resources. So, being able to choose a name that will be found for a similar situation later might seem wise.
For my part, I always put a little extra extension to always find my resources (* .mat = material, an old habit). Just to not add to the ambient mess. Indeed, the more you will advance in the tutorials, the more you will see that your final scene will bring together an impressive number of diverse and varied elements (the resources).

  • 3. Drag and drop the bottom view to the top to split your workspace in two
  • 4. Change the bottom view to the node editor
► Show Spoiler
► Show Spoiler
You should have this:
Scroll up or down into the view to zoom in or out
► Show Spoiler
Into the node editor hit :

Shift + A → Textures → Voronoi Texture - left click to anchor
+
Shift + A → Color → Invert - left click to anchor

Plug all shaders (drag and drop from a shader dot to another) before the BSDF diffuse, like this:
► Show Spoiler
Back to our main screen: Now go at the bottom of the 3D view, to the Viewport Shading and select "Rendered"
► Show Spoiler
You should have something like this:
► Show Spoiler
Ugly isn't it? Be patient:
Look at the "Scale" parameter on the first node (Voronoi Texture), and enter different values to test it. The bigger the values is, the smaller the white dots are, so the lower the value is the bigger the dots are.
These white dots will simulate basic solar spots, and the darker areas, the solar crust, so play it until your like. For myself I did set it to 100.
► Show Spoiler
Now let's put colors on this, hit:

Shift + A → Color → MixRGB - left click to anchor and plug it between the Invert and Diffuse BSDF nodes like this:
► Show Spoiler
Then choose a color for the spots (brighter) and the crust (darker), Here are the proposed hexadecimal values for a yellow star:

Bright Yellow : E7E287
Orange : C36615
► Show Spoiler
► Show Spoiler
Okay, save this if it is not already done

...to be continued. Next: The sun atmosphere and a bit compositing.
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

User avatar
keltwookie
Site Admin
Posts: 134
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

Re: [Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Post by keltwookie » Thu Nov 30, 2017 12:47 am

Get back in "Solid" view for now, Then hit : Ctrl + Shift + Zero to center the camera on the view.
And first of all, to make our mesh look like a bit more like a star, replace the BSDF diffuse shader by an Emission one (a forgetting from my part, sorry).
► Show Spoiler
  • 1. Select the Ico Sphere then hit Shift + D to duplicate the mesh. Hit Esc to let this new mesh centered to the previous one.
    Type S to enlarge slightly. On the left side of the viewport, set the transformation vectors X, Y, and Z to 1,010, so very close to the original Ico Sphere.
  • 2. Rename this new sphere « Yellow Sun Atmosphere ».
  • 3. Select the material tab, disable « yellow.sun.mat » by clicking on « - »
  • 4. Create a new one we will call, for example « yellow.sun.atm.mat ».
► Show Spoiler
► Show Spoiler
Before continuing, we will improve the rendering by creating a darker background:
Into the right panel :
  • 1. Select the World tab
  • 2. Color the background in black (hex=000000)
► Show Spoiler
Get back to our texture and select the material tab
Into the viewport of the node editor :
Shift+A → Shaders → Transparent BSDF
+
Shift+A → Shaders → Mix Shader
Then connect the nodes and color the Diffuse BSDF (here : hex= FFC774), then into the Viewport Shading, switch to « Rendered »
► Show Spoiler
Still into the node editor :
Shift+A → Input → Layer Weight
Here, the Blend value will be set to 0,350 to distinguish the atmosphere without too much blur the texture of the star.
And to rebalance the brightness, we add an Emission shader between the layer weight and the mix shader :
Shift+A → Shader → Emission
► Show Spoiler
Now, click on the Compositing button and check «Use nodes »
► Show Spoiler
► Show Spoiler
Hit F12 to make a rendering, then :
Shift+A → Converter → ID Mask
- Then re-connect from the Depth instead of Image
- To select our star, set the index on 3 into the ID Mask :
► Show Spoiler
Then :
Shift+A → Color → Mix
Connect the output of the ID Mask as factor, then connect the Render Layers from the image output to both image inputs of the Mixer
► Show Spoiler
Let’s add now a glare effect :
Shift+A → Filter → Glare
Replace « Streaks » by « Fog Glow » then set the Treshold to zero and change the size to clearly distinguish the effect.
Note : Be careful with this parameter, it must be kept in mind that compositing will affect the whole scene. For my part, I kept it to 8.
► Show Spoiler
To finnish, duplicate the mix node (Shift+D), then replace « Mix » by « Screen » and connect the node like this :
► Show Spoiler
Downloadable PDF Version

Next part : Create a nebula as background
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

User avatar
keltwookie
Site Admin
Posts: 134
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

Re: [Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Post by keltwookie » Thu Nov 30, 2017 10:06 pm

Part 2 : Create a nebula
  • 1. Click on the Shaders button :
► Show Spoiler
  • 2. Click on World
  • 3.Switch to the 3D view into the upper viewport.
► Show Spoiler
  • 4. Into the 3D viewport, switch to a larger view for the scene, then set the camera (Ctrl+Alt+Zero)
  • 5. Switch to rendered mode into the 3D viewport
► Show Spoiler
Back to the node editor :
Shift+A → Texture → Noise texture
+
Shift+A → Converter → Color ramp
► Show Spoiler
  • 1. Into the color ramp, select the right cursor then assign the color of your choice. Then move the left cursor to center to clearly distinguish the background
  • 2. Into the noise texture, set the Detail value to 16, then play with the size value, in order to obtain the desired effect.
► Show Spoiler
  • Duplicate the first two nodes (Shift+D), then add a mix node :
    Shift+A → Color → Mix RGB
  • Change « Mix » to « Screen » and set the factor on 1
  • Assign the color of your choice
  • Review all parameters again to get the desired effect
► Show Spoiler
Let’s add now brighter areas to our nebula :
Shift+A → Texture → Noise texture + Shift+A → Converter → Color ramp + Shift+A → Color → Mix RGB
Switch the mix node to dodge mode and set the factor on 1. Set the parameters to your like
Note : Regularly check that there are not too saturated areas into the 3D view.
► Show Spoiler
That's it, our nebula is ready. Of course, it is possible to add other colors by duplicating parts of the above configuration, but it will increase the number of parameters to manage, and therefore, will greatly complicate the task to obtain a harmonious view.

Part 2 - Downloadable PDF Version

Next in part 3 : « My God ! It’s full of stars ! »
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

User avatar
keltwookie
Site Admin
Posts: 134
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

Re: [Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Post by keltwookie » Fri Dec 01, 2017 5:52 pm

Part 3 : Create Star fields

We will first group our nebula shader into one set. Indeed, afterwards, we could have trouble to manage the whole thing..
  • 1. Into the node editor, hit N to display the tool panel
  • 2. Shift+A → Layout → Frame
    Adjust the size of this set according to the layout of the shader nodes
  • 3. Select the whole nebula shader (Shift+B)
Left click to anchor
  • 4. Into the tool panel, rename the frame, in our case : Nebula
  • 5. By the way, we could add a color.
► Show Spoiler
Let’s start by disconnecting the nebula shader (we will reconnect it later). Indeed, it will be more easy to see our star fields, then :
  • Shift+A → Texture → Noise Texture
  • Shift+A → Color → Color ramp
Some explanations of the parameters on Blender Stack Exchange :
Noise Texture Scale. This controls the size and amount of stars. Higher scale means more, smaller stars; smaller scale means less, larger stars.
Noise Texture Detail. This will adjust the shape and variation in brightness in the stars. Higher value will mean more irregularly shaped stars, but there will be a greater variation in the brightness of the stars.
Color Ramp Swatches. Adjusting the color swatches on the Color Ramp will change the size and shape of the stars. The farther apart the swatches are the bigger and more irregularly shaped the stars will be.
Source : https://blender.stackexchange.com/quest ... -in-cycles
► Show Spoiler
► Show Spoiler
We could stop right here, after all, we have the main thing, a star background that fits. But we will add another star field we will colorize:

Duplicate the two previous nodes (Shift+D), then add a mixer :
  • Shift+A → Color → Mix RGB
  • Change « Mix » for « Add » and set the factor on 1.
  • Choose the color into the color ramp, then set different values into the noise texture, as previously indicated, to change the amount and size :
► Show Spoiler
We will now increase the brightness of this second star field :
  • Shift+A → Color → RGB Curves
  • Shift+A → Color → Bright/Contrast
Set the parameters again if needed
► Show Spoiler
Let’s go crazy by adding a third field
- Duplicate the fourth previous nodes then add an additional mixer :
► Show Spoiler
Let's group this shader together :
► Show Spoiler
We will now mix our two set of nodes :
- Shift+A → Color → Mix RGB
► Show Spoiler
Here we are, of course, this is far from being perfect and some parameters would have to be reviewed to harmonize the whole thing. It’s up to you.

Part 3 - Downloadable PDF Version

Next in part 4 : Create a planet
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

User avatar
keltwookie
Site Admin
Posts: 134
Joined: Mon Apr 17, 2017 6:42 am
Location: Kashyyyk
Contact:

Re: [Beginner Tutorial] Blender 2.79+Cycles - Create a full space environment with shaders (procedural).

Post by keltwookie » Fri Dec 15, 2017 3:35 pm

Part 4 : Create a planet

We will first disable the background previously created, just to have a non-polluted rendering by the various colors used. So, unplug the nebula and stars shaders (we will reconnect later), then adopt a resolutely black background, so we will have a rendering as fair as possible about the colors for our planet.
► Show Spoiler
Then select the lamp, check "Use Nodes" and set the force to 500. This will distinguish the colors of our future planet. Of course, this setting is largely exaggerated and we will take care of the final lighting of our scene later.
► Show Spoiler
Once done, return to the 3D viewport and adopt a front view (1 on the numeric keypad).
  • 1. Center the pivot point on the 3D cursor. Everyone will do as he wants, but for me, I find it more convenient.
  • 2. Lower the sidebar in the viewport 3D tool panel until you see the cursor position. Adjust it to not generate our future mesh right in the star (here x = 8 )
► Show Spoiler
  • 3. Create an Ico Sphere (Shift+A → Mesh → Ico Sphere)
  • 4. Set subdivisions to 5 (and not 6 as in Part 1), then smooth
► Show Spoiler
  • 5. Once generated, create a new material for our planet (here : planet.mat)
  • 6. Go to the node editor, making sure to select the appropriate buttons.
► Show Spoiler
From all the video tutorials on the subject that I could see on the Internet, the basic practice remains the same, so the use of a noise texture + color ramp(s)

Let’s start by adding a noise texture :
Shift+A → Texture → Noise Texture
Then connect the factor output of this node to the displacement input of the material output node:
► Show Spoiler
Switch to the rendering mode and align the view on the mesh to distinguish the changes made.
► Show Spoiler
It is now time of carving the basic reliefs of our planet (here: terrestrial type), so for the parameters of the texture noise and for our example:
  • Scale = 6
  • Detail = 16 (maximum)
  • Distortion = 0.500
These values are of course given as an indication, we still can change these parameters to our like, in this case, it will create an Earth type planet with oceans.
  • The higher the scale value will be, more the generated forms will be small and numerous.
  • The higher the detail value will be, the higher the level of detail will obviously be.
  • The higher the distortion value will be, more the shapes generated will be curved and elongated.
► Show Spoiler
Add now a color ramp and insert it between the noise texture and the material output :
Shift+A → Converter → Color Ramp
Play now with the left cursor to delineate ocean surfaces and land strips. In our example, the value will be set to 0.450 :
► Show Spoiler
Now let’s add some colors :
Shift+A → Converter → Color Ramp
Connect this new node from the factor output of the noise texture to the color input of the Diffuse BSDF node, then set the left cursor to 0.500 :
► Show Spoiler
Set a blue color (here hex=000E8F) instead of black, so to the left cursor :
► Show Spoiler
Bring the right cursor (white color) very close to the previous one (0.501).
► Show Spoiler
Add a third cursor with the + button that we will set this time to 0.502 with a hex value of 8E7F5B. Then a fourth one around 0.520 with an hex value of 0E4600 :
► Show Spoiler
Note: We could completely nuance colors (ocean depths, beaches, mountains, glaciers, etc.) by multiplying the previous operation. But the purpose was to keep this tutorial as simple as possible and to master the procedure. So, feel free to improve the texture of this planet according to your artistic taste or sense of realism.

Create an atmosphere :
  • 1. Switch to solid view
  • 2. Select the planet if not already done
  • 3. Then set the cursor to the center: Shift+S → Cursor to Selected :
► Show Spoiler
  • Duplicate the Ico Sphere (Shift+D), then hit « Esc » to not deviate from the center
  • Switch to the wireframe view (Z) then enlarge slightly (S) this new mesh (validate by left click or Enter) we will rename, for example, Planet Atmosphere :
► Show Spoiler
  • Switch again to solid view (Z), then create a new material we will name planet.atm.mat
    Into the node editor :
  • Shift+A → Shader → Emission
  • Shift+A → Shader → Mix Shader
  • Set the colors of the Diffuse BSDF and Emission nodes (hex=C9FFFE), then set the factor of the mix shader on a very low value (here : 0.002)
  • Connect the whole thing and switch to the rendered mode :
► Show Spoiler
Add 2 Transparent Shaders + 2 Mix Shaders + a Fresnel node + a Color Ramp, so :
  • Shift+A → Shader → Transparent BSDF (x2)
  • Shift+A → Shader → Mix Shader (x2)
  • Shift+A → Input → Fresnel
    *]Shift+A → Converter → Color Ramp
  • Set the 2nd mix shader to 0.415, then invert both white and black cursors.
  • Set the left cursor (white) on 0.045 and the right cursor (black) to 0.120. Add a 3rd cursor, white this time (hex=FFFFFF) with the + button and set it to 0.250
  • Change Linear to B-spline :
► Show Spoiler
Before moving on, some explanations:

Fresnel?
https://en.wikipedia.org/wiki/Augustin-Jean_Fresnel
IOR?
Means: Index Of Refraction
https://en.wikipedia.org/wiki/Refractive_index
A list of these indexes:
https://pixelandpoly.com/ior.html

Personally, I left the default value.

Create clouds :


Repeat the creation operations of new mesh and new material described into the previous paragraph for the clouds :
► Show Spoiler
Then into the node editor :
  • Shift+A → Texture → Noise Texture
    Scale = 4.5
    Details = 16
    Distortion = 0
  • Shift+A → Converter → Color Ramp
    Left cursor = 0.470
    Right cursor = 0.785
  • Shift+A → Shader → Transparent BSDF
  • Shift+A → Converter → Math
    Instead of « Add », set it to « Multiply »
    Value = 3
  • Shift+A → Converter → Math
    Instead of « Add », set it to « Multiply »
    Value = 2
Then connect like this :
► Show Spoiler
Here we are !

Part 4 - Downloadable PDF Version

Next and last part: Lighting and animation
"Earth is the cradle of Humanity, but we don't leave in a cradle forever." Konstantin Tsiolkovsky (1857-1935)

Post Reply