In this recipe, we will create a spaceship hull material. We will add random, tiny light windows based on the values of procedural textures, and the spaceship's logo as if it were painted in red on the hull, as shown in the following screenshot:
The final, rendered spaceship hull material assigned to a displaced Torus primitive
Getting ready
To start creating this spaceship hull, we need the spaceship and space first. Follow these steps to build a quick and easy model and set up the scene:
Start Blender and switch to the Cycles Render engine. Select the default Cube and delete it.
With the mouse arrow in the 3D view, press Shift + A and add a Torus primitive (press Shift + A and navigate to Mesh | Torus). In Edit Mode, scale it to at least twice its current size (press A to select all the vertices, then type S, enter 2, and press Enter).
Exit Edit Mode, and in Outliner, select the Lamp object. In the Object data window, change it to Sun. Then set the Size value to 0.050. Click on the Use Nodes button and set the Strength value to 10.000. Change the Color value of RGB to 0.800.
Go to the World window and click on the Use Nodes button under the Surface subpanel. Click on the little square with a dot to the right of the Color slot. From the menu, select Sky Texture. Set the Strength to 0.100.
Select the Camera, and in the Transform panel, set the Location values of X to 6.10677, Y to -0.91141, and Z to -2.16840. Set the Rotation values of X to 112.778°, Y to -0.003°, and Z to 81.888°.
Go to the Render window, and under the Sampling subpanel, set the Samples to 25 for Preview and 100 for Render. Then set the Clamp Indirect value to 1.00, but let the Clamp Direct value remain as 0.00. Go to the Film subpanel and check the Transparent item. Then set the output File Format to RGBA.
Under the Light Paths subpanel, disable both the Reflective and Refractive Caustics items. Set Filter Glossy value to 1.00. Under the Performance subpanel, set the Viewport BVH Type to Static BVH (this should speed up the rendering a bit, considering the fact that the model is static and doesn't change shape). Check the Persistent Images and Use Spatial Splits items.
Press N with the mouse arrow in the 3D view to close the Properties panel. Then press T to get rid of the Tool Shelf panel. Split the 3D view into two rows. Convert the upper row to a Node Editor window.
Split the bottom window into two parts. Convert the left part to a UV/Image Editor window. Select Torus and press Tab to go to Edit Mode. In the window toolbar, change the selection mode to Face select. Select only one face on the mesh (whichever you prefer). Press the A key twice to select all the faces, and keep the first face selected as the active face. Then press the U key. In the UV Mapping pop-up menu, select the Follow Active Quads item, and then in the next pop-up menu set Even as Edge Length Mode. Click on the OK button.
With the mouse arrow in the UV/Image Editor window, press A to select all the vertices of the UV islands. Then scale them to one-third of their current size (press S, enter digit .3, and press Enter). Press Tab to exit Edit Mode, and change UV/Image Editor to 3D View. Convert the right 3D viewport to a Camera view by pressing the 0 key on the numeric keypad (with the mouse arrow in the 3D view).
Go to the Object modifiers window and assign a Subdivision Surface modifier to Torus. Set the Subdivisions level to 4 for both View and Render. Set the Camera view mode to Rendered and go to the Material window.
How to do it...
Now let's start creating the material. The steps to create a basic hull shader are as follows:
Click on New in the Material window under the main Properties panel or in the Node Editor toolbar. Rename the new material spacehull.
In the Material window, switch the Diffuse BSDF node with a Mix Shader node. Label it as Mix Shader1. In the first Shader slot, select a new Mix Shader node (label it as Mix Shader2), and in the second slot, select an Anisotropic BSDF node.
In the first Shader slot of the Mix Shader2 node, select a Diffuse BSDF node, and in the second slot, select a Glossy BSDF node. Set the Distribution of both the Glossy BSDF and Anisotropic BSDF nodes to Ashikmin-Shirley.
In the Anisotropic BSDF shader node, set the Rotation value to 0.250. In the Diffuse BSDF node, set the Roughness value to 0.500.
Add a new Mix Shader node (press Shift + A and navigate to Shader | Mix Shader) and paste it between the Mix Shader1 and the Material Output nodes. Label it as Mix Shader_Spec_Amount and connect the output of the Diffuse BSDF node to the first Shader input socket (so that the link from the Mix Shader2 node automatically switches to the second socket). Set the Fac value to 0.300.
Add a Fresnel node (press Shift + A and navigate to Input | Fresnel). Connect its output to the Fac input sockets of the Mix Shader1 and Mix Shader2 nodes. Set the IOR value to 100.000.
Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select all the nodes except the Material Output node. Then select the Frame and press Ctrl + P to parent all of them. Label the frame as SHADER, as shown in the following screenshot:
The SHADER frame
The steps to create hull's panels are as follows:
Add a Texture Coordinate node (press Shift + A and navigate to Input | Texture Coordinate), a Mapping node (press Shift + A and navigate to Vector | Mapping), two Image Texture nodes (press Shift + A and navigate to Texture | Image Texture), and one Musgrave Texture node (press Shift + A and navigate to Texture | Musgrave Texture).
Label the textures as Image Texture1_Hull, Image Texture2_Hull, and Musgrave Texture_Hull. Place them in a column.
Press Shift + D to duplicate the Mapping node twice. Label the nodes as Mapping1_Hull, Mapping2_Hull, and Mapping3_Hull. Place them in a column to the left of the texture nodes. Connect the UV output of the Texture Coordinate node to the Vector input sockets of the three Mapping nodes. Connect the Vector output of each of the Mapping nodes to the Vector input socket of each of the texture nodes.
Click on the Open button in the Image Texture1_Hull node to load image spacehull.png. Then click on the little arrows to the left of the Open button in the Image Texture2_Hull node to select the same image texture. Go to the Musgrave Texture node and set the Scale value to 115.500, the Detail value to 4.500, the Dimension value to 0.200, and the Lacunarity value to 0.600.
Go to the Mapping1_Hull node and set the Scale value of X to 2.000, Y to 4.000, and Z to 6.000. Then go to the Mapping2_Hull node and set the Scale value of Y to 2.000 and Z to 3.000. Next, go to the Mapping3_Hull node and set the Scale value of Z to 0.100.
Add a MixRGB node (press Shift + A and navigate to Color | MixRGB). Set Blend Type to Multiply and the Fac value to 1.000. Label it as Multiply1_Hull. Then connect the Color output of the Image Texture1_Hull node to the Color1 input socket and the Color output of the Image Texture2_Hull node to the Color2 input socket.
Press Shift + D to duplicate the Multiply1_Hull node, change Blend Type to Overlay, and label it as Overlay_Hull. Set the Fac value to 0.050. Connect the output of the Multiply1_Hull node to the Color1 input socket and the Color output of the Musgrave Texture node to the Color2 input socket.
Add a ColorRamp node (press Shift + A and navigate to Converter | ColorRamp), label it as ColorRamp_Hull, and connect the output of the Overlay_Hull node to its Fac input socket. Move the black color stop to the 0.500 position.
Add a Bump node (press Shift + A and navigate to Vector | Bump), label it as Bump_Hull, and connect the output of the Multiply1_Hull node to the Height input socket. Set the Strength value to 0.400.
Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select the three Mapping nodes, the two Image Texture nodes, the Musgrave Texture node, the Bump node, the ColorRamp node, the two MixRGB nodes, and then the Frame. Press Ctrl + P to parent them. Label the frame as HULL, as shown in the following screenshot:
The HULL frame
Connect the Normal output of the Bump_Hull node to the Normal input sockets of the Diffuse BSDF, Glossy BSDF, and Anisotropic BSDF nodes inside the SHADER frame. Then connect the output of the Overlay_Hull node to the Color input sockets of the same Diffuse BSDF, Glossy BSDF, and Anisotropic BSDF nodes. Next, connect the Color output of the ColorRamp_Hull node to the Roughness input sockets of the Glossy BSDF and Anisotropic BSDF shader nodes, as shown in this screenshot:
The output of the HULL frame connected to the SHADER frame nodes
The steps to create hull's logo are as follows:
Add a new Mapping node (press Shift + A and navigate to Vector | Mapping) and a new Image Texture node (press Shift + A and navigate to Texture | Image Texture). Label them as Mapping4_Name and Image Texture3_Name, respectively. Connect the UV output of the Texture Coordinate node to the Mapping4_Name node, and the output of this node to the Vector input socket of the Image Texture_Name node.
Click on the Open button of the Image Texture node and load the spacehull_name.png image, an image texture of the ARGUS logo with a transparent background (alpha channel).
Go to the HULL frame and add a MixRGB node (press Shift + A and navigate to Color | MixRGB). Label it as Mix_Hull_Name and paste it between the Overlay_Hull node and the Diffuse BSDF shader node. Then connect itsColor output to the Color input socket of the Glossy BSDF and Anisotropic BSDF shader nodes.
Connect the Color output of the Image Texture_Name node to the Color2 input socket of the Mix_Hull_Name node. Then connect the Alpha output of the Image Texture_Name node to the Fac input socket of the Mix_Hull_Name node.
Go to the Mapping4_Name node and check both the Min and Max items. Then set the Location value of X to -3.300 and Y to 1.000. Set the Scale value of Y to 2.500. (These values depend on the scale and location you want for your logo on the spaceship; just experiment looking at the real-time-rendered preview.)
Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select the Mapping4_Name node, the Image Texture3_Name node, and then the Frame. Press Ctrl + P to parent them. Label the frame as NAME, as shown in the following screenshot:
The ARGUS logo on the hull
The steps to create the windows are as follows:
Add a new Mapping node (press Shift + A and navigate to Vector | Mapping) and two Image Texture nodes (press Shift + A and navigate to Texture | Image Texture). Label them as Mapping5_Windows, Image Texture4_Windows, and Image Texture5_Windows. Connect the Texture Coordinate node's UV output and the Mapping node's output to the Image Texture nodes as usual. Then set the Mapping node's Scale values to 10.000 for the three axes.
Click on the Open button of the Image Texture4_Windows node and load the spacehull_windows_lights.png image. Then click on the Open button of the Image Texture5_Windows node and load the spacehull_windows_bump.png image. Set Color Space for both the image nodes to Non-Color Data.
Add two MixRGB nodes (press Shift + A and navigate to Color | MixRGB). Set Blend Type to Multiply and Fac values to 1.000. for both the nodes Label them as Multiply2_Windows_Light and Multiply2_Windows_Bump. Connect the output of the Image Texture4_Windows node to the Color1 input socket of the Multiply2_Windows_Light node, and the output of the Image Texture5_Windows node to the Color1 input socket of the Multiply2_Windows_Bump node.
Add a ColorRampnode (press Shift + A and navigate to Converter | ColorRamp), label it as ColorRamp_Windows, and move the black color stop to the 0.919 position. Connect the output of the Multiply2_Windows_Light node to its Fac input socket.
Add a new Bump node (press Shift + A and navigate to Vector | Bump), label it as Bump_Windows, and connect the output of the Multiply2_Windows_Bump node to the Height input socket. Set the Strength value to 50.000.
Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select the Mapping5_Windows node, the Image Texture4_Windows and Image Texture5_Windows nodes, the two MixRGB nodes, the ColorRamp_Windows and the Bump_Windows nodes, and then the Frame. Press Ctrl + P to parent them. Label the frame as WINDOWS, as shown in the following screenshot:
The WINDOWS frame
Add a Vector Math node (press Shift + A and navigate to Converter | Vector Math) and set Operation to Average. Connect the Normal output of the Bump_Windows node inside the WINDOWS frame to the first Vector input socket, and the Normal output of the Bump_Hull node inside the HULL frame to the second Vector input socket. Then connect the Normal output of the Average Bump_Hull node to the Normal input sockets of the Diffuse BSDF, Glossy BSDF, and Anisotropic BSDF shader nodes, as shown in this screenshot:
The windows bump visible on the hull
The steps to create the location mask for the windows are as follows:
Add one more Mapping node (press Shift + A and navigate to Vector | Mapping) and four Checker Texture nodes (press Shift + A and navigate to Texture | Checker Texture). Connect the Texture Coordinate node and the nodes as usual. Then label them as Mapping6_Mask, Checker Texture1_Mask, Checker Texture2_Mask, Checker Texture3_Mask, and Checker Texture4_Mask. In all, the four Checker Texture nodes change Color2 to pure black.
Add a MixRGB node (press Shift + A and navigate to Color | MixRGB), set Blend Type to Screen and Fac value to 1.000, and label it as Screen_Mask. Connect the Color output of the Checker Texture1_Mask node to the Color1 input socket of the Screen_Mask node, and the Color output of the Checker Texture2_Mask node to the Color2 input socket.
Press Shift + D to duplicate the MixRGB node, change the duplicate node's Blend Type to Add, and label it as Add_Mask1. Connect the output of the Screen_Mask node to the Color1 input socket. Then connect the Color output of the Checker Texture3_Mask node to the Color2 input socket.
Press Shift + D to duplicate the Add_Mask1 node, and label the duplicate as Add_Mask2. Connect the output of the Add_Mask1 node to the Color1 input socket. Then connect the Color output of the Checker Texture4_Mask node to the Color2 input socket.
Add a ColorRamp node and label it as ColorRamp_Mask. Connect the output of the Add_Mask2 node to its Fac input socket. Then move the black color stop to the 0.100 position and the white color stop to the 0.000 position. Set Alpha of the black color stop to 0.000.
Go to the Checker Texture nodes. Set the Scale value for the Checker Texture1_Mask node to 1.600, the Checker Texture2_Mask node to 8.800, the Checker Texture3_Mask node to 3.000, and the Checker Texture4_Mask node to 9.700. Go to the Mapping6_Mask node and set the Scale values to 0.500 for all the three axes.
Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift to select the recently added nodes and then the Frame. Press Ctrl + P to parent them. Rename the frame as MASK WINDOWS as shown in the following screenshot:
The MASK WINDOWS frame
The steps to create the final connections are as follows:
Connect the Color output of the ColorRamp_Mask node to the Color2 input sockets of both the Multiply2_Windows_Lights and Multiply2_Windows_Bump nodes, as shown in this screenshot:
The MASK WINDOWS frame output connected to the WINDOWS frame nodes
Go to the SHADER frame and add a Mix Shader node (press Shift + A and navigate to Shader | Mix Shader). Label it as Mix Shader3 and paste it between theMix Shader_Spec_Amount and the Material Output nodes.
Connect the Color output of the ColorRamp_Windows node inside the WINDOWS frame to the Fac input socket of the Mix Shader3 node, as shown in the following screenshot:
The output of the WINDOWS frame connected to the SHADER frames nodes and the result in the Rendered preview
The steps to create the light emitter for the windows are as follows:
Inside the SHADER frame, add an Emission shader node (press Shift + A and navigate to Shader | Emission), a ColorRamp node (press Shift + A and navigate to Converter | ColorRamp), and an Object Info node (press Shift + A and navigate to Input | Object Info). Label the ColorRamp node as ColorRamp_Lights_Colors, change Interpolation to Constant, and add six more color stops (eight total). Change the color values alternatively of R to 0.800, G to 0.517, B to 0.122; and R to 0.800, G to 0.198, and B to 0.040 (or any other color you prefer).
Connect the Random output of the Object Info node to the Fac input socket of the ColorRamp node, and the output of this node to the Color input socket of the Emission node.
Connect the Emission node's output to the second Shader input socket of the Mix Shader3 node. Then set Strength to 3.000, as shown in the following screenshot:
The windows on the hull getting illuminated by the ColorRamp_Lights_Colors node and an Emission node output connected to the SHADER output
How it works...
From step 1 to step 7, we built the general shader for the metallic hull, which is similar to the metal node group we saw in Chapter 4, Creating Man-made Materials in Cycles. This was achieved by mixing Diffuse BSDF and Glossy BSDF shaders with an Anisotropic BSDF node on a ground with a quite high IOR value (100.000), and through the usual Mix Shader nodes. We added one more Mix Shader node (Mix Shader_Spec_Amount) to include the possibility of setting more specularity than anisotropy, and vice versa.
From step 8 to step 18, we built the HULL frame group by superimposing two differently scaled versions of the same image. Then they could be used for the color, bump, and specular components. These components were obtained by contrasting the paneling through a ColorRamp node and then going straight to the Glossy BSDF shader's roughness and the Anisotropic BSDF shader, to add a metallic look. The mixture of both Glossy BSDF and Anisotropic BSDF is made on the ground of a Fresnel node set to 100.000. A very high value like this is needed because the specularity is then mixed again with the Diffuse BSDF component to the purpose to obtain a slider to tweak the effect.
From step 19 to step 24, we added the red hull's logo, ARGUS, using its own alpha channel to overimpose it on the hull surface's panels..
From step 25 to step 30, we built the WINDOWS frame group.
In step 31, we merged (averaged) the bump effect of the windows with the bump effect of the hull's panels.
From step 32 to step 38, we made the masking for the windows to give them a random appearance.
From step 39 to step 41, we simply connected the various frames' output.
From step 42 to step 44, we created the light-emitting material for the windows. Note that the WINDOWS_ MASK frame group provides the masking for the windows' positions. The WINDOW frame group provides the whiteness values for the windows, the bump, and the last nodes added to the SHADER frame the light emission based on the output of the previous frame groups.
There's more...
The appearance of the hull can be improved even further using some displacement to add geometric details to the spaceship surface, which (at the moment) is a bit too smooth:
Go to the Object modifiers window and assign a second Subdivision Surface modifier to Torus. Set the Subdivisions levels to 2 for both View and Render.
Assign a Displace modifier. Then click on the Show texture in texture tab button on the right side of the Texture slot. In the Textures window, click on the New button. Then replace the default Clouds texture with an Image or Movie texture.
Click on the Open button and load the spacehull_displ.exr texture.
Go back to the Object modifiers window and set the displacement's Strength value to 0.200. In the Texture Coordinates slot, select UV.
This way, the displacement features get mixed with the hull bump panels of the shader, giving a nice result. The spacehull_displ.exr texture is a 32-bit float displacement map created and stored in the Blender Internal engine. I modeled the Planes and scaled Cubes a simple greeble panel, then I baked the displacement on a different and unwrapped Plane, as shown in the following screenshot:
The greeble scene ready for the baking
Tip
If you want to take a look at the baking scene, open the 9931OS_06_greeble.blend file.
Finally, we can try to set the first Subdivision Surface modifier level to 4 and lower the second Subdivision Surface modifier's level to 1. Then, starting from the top one, apply all the modifiers. You will inevitably lose the details but will obtain a much lighter mesh—589,824 faces against the initial 2,359,296—and considering the fact that most of the details come from the texturing, the result looks pretty good (at least from a distance). It also looks good if the shading is set to Flat instead of Smooth.