Skip to content

💻 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.

  1. First activate the Rendered shading to see what kind of materials we are actually applying by pressing Z in the 3D Viewport panel and selecting Rendered from the radial pie-menu.
  2. 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.
  3. 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.
  4. 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.

  1. Select the groundplane 3D object.
  2. Add a Image texture-node to the Shader Editor graph of the groundplane with Shift-A > Texture > Image Texture.
  3. Connect the Color output of this node to the Base color input of the Principled BSDF-node.
  4. 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 the blue_painted_planks_diff_4k.png image from the data/wood_textures/ directory and press Open 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.

  1. Before we can do that we first need to add the texture coordinates to the graph with Shift-A > Input > Texture Coordinates and connect the UV output to the Vector input of the Image Texture-node.
  2. 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.
  3. Now on the Mapping-node change the Scale parameter x,y and z to 2. 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.

  1. Select the previously added Image Texture-node and press Shift-D and place the new duplicated node underneath the other Image Texture-node.
  2. Connect its Vector input to the Vector output of the Mapping-node just like the other Image Texture-node and connect the Color output to the Roughness input of the Principled BSDF-node.
  3. 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 the blue_painted_planks_rough_4k.png from data/wood_textures.
  4. 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 the Color Space parameter of this Image Texture-node to Non-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.

  1. As the previous Image Texture-node we again need to make a new one by duplicating (see step 8).
  2. Again the Mapping-node Vector output needs to be connected to the new Image Texture-node Vector input. The Color output however needs to go to a Normal Map-node.
  3. Add a Normal Map-node with Shift-A > Vector > Normal Map and connect the Image Texture-node Color output to the Normal Map-node Color input and connect the Normal Map-node Normal output to the Principled BSDF-node Normal input.
  4. Again this is also not a color so the Color Space needs to be set to Non-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!

  1. Select the fishskin 3D object.
  2. 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 called fishskinmat.
  3. 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.
  4. 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.
  5. Add a new material by clicking the New button in the middle of the top bar of the Shader Editor panel.
  6. 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).

  1. To assign vertices we need to be able to select them and this can be done in the Edit Mode of the 3D 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) press TAB.
  2. 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 pressing B in the 3D Viewport-panel and dragging over the area you want to select.
  3. With these vertices selected press the Material slots button, select the fishskintransparentmat-material and press the Assign-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!

  1. In the Shader editor add a Mix Shader-node with Shift-A > Shader > Mix Shader.
  2. Drag this Mix Shader-node over the edge connecting the Principled BSDF-node and the Material Output-node to place it connected in between.
  3. Now add a Transparent BSDF with Shift-A > Shader > Transparent BSDF.
  4. Connect the BSDF output to the Mix Shader-node Shader input.
  5. 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.

  1. 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.
  2. Add a Image Texture-node to the material with Shift-A > Texture > Image Texture and connect the Color output to the Principled BSDF-node Base Color input and open the carp.jpg texture from the data/ directory.
  3. Next add a Texture Coordinate node with Shift-A > Input > Texture Coordinates and connect the UV output to the Image texture-node Vector input.

This fish is now black because the UV coordinates are not defined yet. That is what we will do in the UV Editor.

  1. Now that we do not need the Shader editor anymore we can replace it with the UV Editor. In the corner of the panel click the Editor Type-button and select the UV Editor from the list.
  2. Before we can start UV-mapping we need to be in Edit mode in the 3D viewport. In the 3D viewport panel press TAB to enter edit mode.
  3. 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.

  1. Press ` (the back-tick) to open the view radial pie-menu and select Right or through the 3D Viewport menu in the header (View > Viewpoint > Camera).
  2. Now press U to open the UV-mapping-menu and select Project 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.

  1. Make sure that everything is still selected and then within the UV Editor press S and scale the UV-coordinates until they aligns with the photo of the carp.
  2. 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.

  1. 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 the UV Editor. This proportional editing moves all UV-coordinates in the adjacent defined radius along with the currently selected UV-coordinates.
  2. Now select a UV-coordinate in the UV Editor that needs to be moved and press G.
  3. While grabbing, scroll with your mouse wheel to decrease or increase the Proportional editing radius and move your mouse to see the effect.
  4. 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.

  1. 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 :( ).
  2. Add a UV Sphere instead with Shift-A > Mesh > UV sphere.
  3. Set the UV Sphere's shading to smooth through the 3D Viewport menu in at the top of the 3D Viewport (Object > Shade Smooth).
  4. 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.
  5. Now change the shading in the 3D viewport to Rendered by pressing Z and then select Rendered. 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 the Render Engine to Cycles.
  6. As you can see the sun is now way too bright. Lower the Strength of the sun from 1000 to 10 in the Light-tab in the Properties-panel. No need to have the power of a 1000 suns.
  7. 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.

  1. 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.
  2. Now click the upper left Editor type dropdown menu (now the Timeline-icon ) and select the Shader Editor.
  3. In the Shader Editor add a new material.
  4. In this material add 2 Image Texture-nodes, 1 Texture Coordinate-node and 1 Displacement-node (Shift-A > Vector > Displacement).
  5. Connect the Texture Coordinate-node UV output to both Image Texture-nodes Vector inputs.
  6. Connect one of the Image Texture-nodes Color output to the Principled BSDF-node Base Color input and the others Color output to the Displacement-node Height input.
  7. Finally connect the Displacement-node Displacement output to the Material output-node Displacement input.
  8. Open the data/moon_textures/lroc_color_poles_8k.tif in the Image Texture-node that is connected to the Principled BSDF-node Base Color.
  9. Open the data/moon_textures/ldem_16.tif in the Image Texture-node that is connected to the Displacement-node Height input.
  10. Then finaly set the Image Texture-node Color Space-parameter of the node with the displacement texture to Non-Color.
  11. Initially the Displacement-node Scale parameter is set way too high making the moon look horrible. Set this parameter to 0.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.

  1. Active the Cycles rendering engine with the Render 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.

  1. Set the Feature Set to Experimental.
  2. This Experimental feature set added an extra section in the current properties panel tab called Subdivision. In this section set Viewport to 2.

Now we need to add a Subdivision modifier that also got a new setting from the Experimental feature set that enables the adaptive displacement.

  1. Add a Subdivision modfier in the Modifier properties-tab of the Properties-panel.
  2. 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.

  1. Change the Displacement setting to Displacement Only in the Properties-panel > Material properties-tab > Settings-section > Surface-subsection.
  2. 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).


Last update: 10 April 2024 15:22:19