💻 The Shader Editor and advanced materials¶
In these two exercises in this chapter you will use the Blender Shader Editor on the familiar iso-surface of a CT scan of a fish from the basic course and try to make a visualization by using an advanced node setup. After that you will make a render of the moon with the high resolution textures of NASA with adaptive subdivision.
💻 The fish¶
When you opened the exercise blend file advanced_materials_assignment.blend
you'll see the white fish iso-surface above a plane white plane. We are going to pimp this scene with advanced materials.
Shader editor materials - Coloring the scene¶
First we will add materials and give each object a different color.
- First activate the Rendered shading to see what kind of materials we are actually applying by pressing
Z
in the 3D Viewport panel and selectingRendered
from the radial pie-menu. - Select the fishskin object and add a new material by clicking the
New
button in the middle of the top bar of the Shader Editor panel. - Now we see a graph appearing with 2 nodes a Principled BSDF-node and a Material output-node also in the side panel you will see the familiar material settings. Change the
Base Color
to an appropriate color of a fish. - Repeat step 2 and 3 for each 3D object in the scene (see Outliner) and give them a color of your choice.
Texture mapping - Placing the fish on a picknick table¶
Now that the scene has some color we can start applying some realistic colors and texture to the ground plane or should we say table? We will do that by adding wood textures to the ground plane and connecting those textures to their appropriate parameters of the Principle BSDF.
- Select the
groundplane
3D object. - Add a Image texture-node to the Shader Editor graph of the groundplane with
Shift-A > Texture > Image Texture
. - Connect the
Color
output of this node to theBase color
input of the Principled BSDF-node. - Now the groundplane doesn't look anything like a picknick table, its pink. This pink color comes from the fact that an image is missing from the Image Texture-node. Open an image by pressing the
Open
-button on the Image Texture-node, this will open a file browser window. Now select theblue_painted_planks_diff_4k.png
image from thedata/wood_textures/
directory and pressOpen Image
.
Now we have our first image mapped on an object! Although you might have noticed that the fish is really small or rather the planks are very big. We are gonna solve that by scaling the texture coordinates.
- Before we can do that we first need to add the texture coordinates to the graph with
Shift-A > Input > Texture Coordinates
and connect theUV
output to theVector
input of the Image Texture-node. - Nothing changed because we didn't apply the scaling yet. Now add a Mapping node with
Shift-A > Vector > Mapping
and drag it on top of the edge between the Texture Coordinate-node and the Image Texture-node and let it go. As you can see it is automatically connected in between the nodes. - Now on the Mapping-node change the
Scale
parameterx
,y
andz
to2
. As you can see that reduced the planks to a smaller and better size.
Tip!
With the Node Wrangler Blender add-on you can just select a texture node and press CTRL+T
to automatically add the Texture Coordinate and Mapping node. Node Wrangler can be added with: Menu-bar Edit > Preferences > Add-ons tab > Type 'Node Wranger' in search > check Node Wrangler add-on to activate
.
Now we'll roughen the planks a bit with a Roughness map, a texture that will be use to change the Roughness
parameter of the Principled BSDF.
- Select the previously added Image Texture-node and press
Shift-D
and place the new duplicated node underneath the other Image Texture-node. - Connect its
Vector
input to theVector
output of the Mapping-node just like the other Image Texture-node and connect theColor
output to theRoughness
input of the Principled BSDF-node. - As you can see became shiny, which wood is not (rotate the view around the object in the 3D Viewport to see the plane from different angles). This is because we haven't changed the texture yet. In this new Image Texture-node
Open
theblue_painted_planks_rough_4k.png
fromdata/wood_textures
. - Now it is still a bit too shiny for wood. This is because the output is interpreted as an
sRGB
value. We need to change theColor Space
parameter of this Image Texture-node toNon-color
. Now the ground plane has the right rough look like wood.
The look of the wood is still very "flat" (the light still bounces of it at a straight angle), this is because we didn't add a normal map to the material yet. This normal map will accentuate all the nooks and crannies naturally present in wood which normally catch light to.
- As the previous
Image Texture
-node we again need to make a new one by duplicating (see step 8). - Again the Mapping-node
Vector
output needs to be connected to the new Image Texture-nodeVector
input. TheColor
output however needs to go to a Normal Map-node. - Add a Normal Map-node with
Shift-A > Vector > Normal Map
and connect the Image Texture-nodeColor
output to the Normal Map-nodeColor input
and connect the Normal Map-nodeNormal
output to the Principled BSDF-nodeNormal
input. - Again this is also not a color so the
Color Space
needs to be set toNon-color
.
Now you have a fully textured wooden ground plane! To see the full effect, rotate the view around it and see the light bounce off the surface based on the different texture types you just applied.
Multiple materials one object - Window to the inside of the fish¶
We only see the fish, not the fish bones. In the Blender Basics course we learned how to reveal the bones on the inside by using a Boolean modifier, but we can achieve the same with just materials!
- Select the
fishskin
3D object. - If everything in the first couple of assignments the fish should already have one material called Material. For administrative reasons lets
rename
the material by clicking its name Material in the middle of the top bar of the Shader Editor panel and typing the new name calledfishskinmat
. - Now left next to the rename box you have drop-down menu called
Slot 1
when you click this you will see the material slots menu. In our case its only one material called fishskinmat. - Now add a new Material slot by clicking the
plus icon
in this menu. The added material slot is still empty and needs a second material. - Add a new material by clicking the
New
button in the middle of the top bar of the Shader Editor panel. - Rename this material to
fishskintransparentmat
.
Now as you can see adjusting any value on the Principled BSDF-node doesn't seem to do anything. This is because there aren't any vertices assigned to this material slot yet (by default all vertices are assigned to the first material slot).
- To assign vertices we need to be able to select them and this can be done in the
Edit Mode
of the3D Viewport
-panel. With the fishskin 3D object selected and the focus on the 3D Viewport-panel (hovering over the 3D Viewport panel with your mouse) pressTAB
. - First press 1 to see the vertices and then select a window of vertices on the side of the fish with the
Border select
tool by pressingB
in the 3D Viewport-panel and dragging over the area you want to select. - With these vertices selected press the
Material slots
button, select thefishskintransparentmat
-material and press theAssign
-button.
Now you can see the selected faces in that selection look different! This is because they are assigned to the second material. Now we'll make the fishskintransparentmat
actually transparent with a combination of the Transparent BSDF and Principled BSDF through a Mix Shader
. That way we can control the amount of transparency!
- In the Shader editor add a
Mix Shader
-node withShift-A > Shader > Mix Shader
. - Drag this Mix Shader-node over the edge connecting the Principled BSDF-node and the Material Output-node to place it connected in between.
- Now add a
Transparent BSDF
withShift-A > Shader > Transparent BSDF
. - Connect the
BSDF
output to the Mix Shader-nodeShader
input. - Now the material is half shaded by the Transparent BSDF-node and half by the Principled BSDF-node. Experiment with the Mix shader-node's
fac
parameter to see how it changes the transparency of the fishskintransparentmat.
Now you have a window looking inside the fish! Now it's time to give the fish some actually fishy colors with the Project from view UV-mapping!
Bonus (Only when you have time left): As you can see the bones also contain the swim bladder which looks the same as the bones because the same material is assigned to it. Try to select the swim bladders vertices and assign a different more fitting material to the swim bladder.
Project from view UV-mapping - Add actual skin to the fish.¶
To add a real fish texture, or actually a photo from a carp, to the fishskin
3D object you can use the technique called Project from view
UV-mapping. For this we introduce a new panel called the UV Editor
. Before we go to the UV Editor
we need to add a Image Texture-node to the fishskinmat
.
- In the Shader Editor select the
fishskinmat
(slot 1) from the Material slot menu in the middle left of the top bar of the Shader Editor. - Add a Image Texture-node to the material with
Shift-A > Texture > Image Texture
and connect theColor
output to the Principled BSDF-nodeBase Color
input and open thecarp.jpg
texture from thedata/
directory. - Next add a Texture Coordinate node with
Shift-A > Input > Texture Coordinates
and connect theUV
output to the Image texture-nodeVector
input.
This fish is now black because the UV
coordinates are not defined yet. That is what we will do in the UV Editor
.
- Now that we do not need the
Shader editor
anymore we can replace it with theUV Editor
. In the corner of the panel click the Editor Type-button and select theUV Editor
from the list. - Before we can start UV-mapping we need to be in
Edit mode
in the 3D viewport. In the 3D viewport panel pressTAB
to enter edit mode. - Now select all geometry by pressing
A
.
To properly project from view you have to choose the right view to project from. We are gonna map a photo of a carp which has been taken from the side. In order to properly map the photo on the 3D object we also need to look at it from the side.
- Press
`
(the back-tick) to open the view radial pie-menu and selectRight
or through the 3D Viewport menu in the header (View > Viewpoint > Camera
). - Now press
U
to open the UV-mapping-menu and selectProject from view
.
Now you can see the UV
coordinates are mapped in the UV Editor
but they are not properly scaled to fit the photo of the carp.
- Make sure that everything is still selected and then within the
UV Editor
pressS
and scale the UV-coordinates until they aligns with the photo of the carp. - Scaling it alone is not enough. The UV-coordinates need to be moved a bit, use
G
to grab the UV-coordinates and translate them to better match the photo.
As you might have noticed it is not possible to completely match the photo without deforming the UV-coordinates.
- Before we start deforming parts of the UV-coordinates you need to activate Proportional editing by pressing the
Proportional editing
button in the top bar of theUV Editor
. This proportional editing moves all UV-coordinates in the adjacent defined radius along with the currently selected UV-coordinates. - Now select a UV-coordinate in the UV Editor that needs to be moved and press
G
. - While grabbing, scroll with your mouse wheel to decrease or increase the Proportional editing radius and move your mouse to see the effect.
- Now with this
Proportional editing
try to match the UV-coordinates to the photo of the carp as good as possible.
Tip!
Whenever you are editing the UV-map in the UV editor it can be difficult to see how the texture is mapped on the 3D-object because of the visibility of all vertices, edges and faces because of the activated Edit mode. You can toggle between Edit mode and Object mode in the 3D Viewport panel to have a better look at the mapped texture.
💻 The moon¶
This moon exercise doesn't have a prepared blend file because you are gonna make it all by yourself! So open a new blend file and start to make the moon.
The basic scene - Sphere, sun and the darkness of space¶
To create the moon we first need to prepare a very simple scene.
- First off we need to remove the Default cube (the cube that comes with a new blend file which only function is to be removed :( ).
- Add a
UV Sphere
instead withShift-A > Mesh > UV sphere
. - Set the
UV Sphere
's shading to smooth through the 3D Viewport menu in at the top of the3D Viewport
(Object > Shade Smooth
). - Select the default
Light
object in the Outliner and change it to a Sun light in the Light-tab in the Properties-panel on the right. - Now change the shading in the 3D viewport to
Rendered
by pressingZ
and then selectRendered
. This rendered view is by default set to Eevee, to change that to Cycles for more realistic lighting go to the Render Properties-tab in the Properties-panel and change theRender Engine
to Cycles. - As you can see the sun is now way too bright. Lower the
Strength
of the sun from 1000 to10
in the Light-tab in the Properties-panel. No need to have the power of a 1000 suns. - Now that we have the sun we need to disable the World-lighting (the grey ambient light) since we only need the sun as a direct light source like it is in space. Go to the World properties-tab in the Properties-panel and set the
Color
in the Surface-section all the way to black.
Now we have the basic scene of a sphere in space, now we are gonna make it look like the moon by adding textures.
Applying a material and texturing the moon - That's one small step...¶
Before we can edit the material we need to open the Shader Editor. For this we need to slightly modify the interface.
- Grab the edge between the 3D viewport-panel and the Timeline-panel by hovering above the edge until you see resize cursor then click and drag the edge until half of the Blender window.
- Now click the upper left Editor type dropdown menu (now the Timeline-icon ) and select the Shader Editor.
- In the Shader Editor add a new material.
- In this material add
2
Image Texture-nodes,1
Texture Coordinate-node and1
Displacement-node (Shift-A > Vector > Displacement
). - Connect the Texture Coordinate-node
UV
output to both Image Texture-nodesVector
inputs. - Connect one of the Image Texture-nodes
Color
output to the Principled BSDF-nodeBase Color
input and the othersColor
output to the Displacement-nodeHeight
input. - Finally connect the Displacement-node
Displacement
output to the Material output-nodeDisplacement
input. - Open the
data/moon_textures/lroc_color_poles_8k.tif
in the Image Texture-node that is connected to thePrincipled BSDF
-nodeBase Color
. - Open the
data/moon_textures/ldem_16.tif
in the Image Texture-node that is connected to the Displacement-nodeHeight
input. - Then finaly set the Image Texture-node
Color Space
-parameter of the node with the displacement texture toNon-Color
. - Initially the Displacement-node
Scale
parameter is set way too high making the moon look horrible. Set this parameter to0.001
.
As you can see it already looks quite like the moon but with some final tweaking you will get even more realism.
Adaptive displacement - Revealing the craters! Mooore details!¶
Everything we have seen until now has been rendered in the default EEVEE rendering engine, which is for visualization purposes very powerful, but if you want to add that extra little realism with adaptive displacement you have to use the Cycles rendering engine.
- Active the
Cycles
rendering engine with theRender Engine
setting in the Rendering properties-tab of the Properties-panel.
While we are there, to be able to use adaptive displacement, we need to activate the Cycles experimental feature set.
- Set the
Feature Set
toExperimental
. - This Experimental feature set added an extra section in the current properties panel tab called
Subdivision
. In this section setViewport
to2
.
Now we need to add a Subdivision modifier
that also got a new setting from the Experimental feature set that enables the adaptive displacement.
- Add a
Subdivision modfier
in the Modifier properties-tab of the Properties-panel. - Enable the Adaptive Subdivision setting in this modifier.
Until now you only saw some slight differences because there is only one setting that has to be changed to make all of this worth it.
- Change the
Displacement
setting toDisplacement Only
in the Properties-panel > Material properties-tab > Settings-section > Surface-subsection. - Now zoom in and toggle to the Edit mode and back, which re-triggers the adaptive subdivision computations, and see the craters in their full glory.
Bonus: For an artists rendition of the moon change the Displacement-node Scale
parameter to a higher value and see how the craters get more noticeable (although less realistic).