Creating a Car Animation blender

Creating a Car Animation
Dr.MohitBansal Profile Pic
Dr.MohitBansal,Canada,Teacher
Published Date:26-10-2017
Your Website URL(Optional)
Comment
Creating a Car Animation In this chapter, we will cover the following recipes in depth: f Setting up the lighting f Creating a car paint material f Creating the materials for the exterior environment f Setting up the scene for the animation f Compositing the scene Introduction In this chapter, we will be creating our first animation in Cycles. This will involve using some new options in Cycles that are made especially for animations. Among other things, we will also learn about new materials and techniques. Here is the final animation that we'll have created at the end of this chapter:Creating a Car Animation Setting up the lighting Let's start with the lights as we always do. For this time in this scene, we will deal with both an exterior and an interior environment. Getting ready We will be using a combination of the sun and environment lighting for the general lighting, plus some emitter and a portal for the interior. To start, open theChapter07.blend file. How to do it... 1. Add sun light, and set the rotation to XYZ 2.85, -37, -22. This can be set from the properties panel of the viewport, which can be activated by pressing N. Rotation is in the Transform panel. 2. In the Lamp menu, set Shadow Size to0.05 and Strength to5. Set color to white. Also make sure that the Cast Shadow option is active. 3. Select the InteriorLights mesh, and add an Emission material to them with a Strength of7 and the RGB color value as 0.520, 0.760, 0.800. Call the material InteriorLights. 4. Select the Portal mesh, and add a material to it. Name itPortal. Delete the default Diffuse BSDF, add Emission BSDF and set Strength to6. 5. In the object menu of the Portal mesh, we need to deactivate the camera, transmission, and shadow-ray visibility. 6. Select the SunDisk mesh, add a new material to it, and name itSun. Make it Emitter with Strength of2. 200Chapter 8 7. Now let's move to the World node editor. Add Sky Texture and an RGB curve. Plug Sky Texture in the RGB curve, and set them as shown in the screenshot. 8. Plug the RGB curve inside the color1 socket of a Color Mix node, and set the mode to Color and the Fac value to0.5. Finally, plug the Color Mix node into a Background node. 9. Now add a Texture coordinate node and an Environment Texture node. Load the vp_sky_v3_047_GOODsmall.jpg file, and use the Generated coordinates for it. 10. Set its rotation to XYZ 0, 180, 0 with a mapping node 11. Plug the Environment Texture inside another Background node. We can either duplicate the other (by pressing Ctrl + D when the node is selected) one or add a new one (Add menu Shader). 12. Add an Add Shader node, and use it to mix the two Background nodes. Finally, set Sky Background Strength to0.4 and Environment Texture Background Strength to2. How it works... The lighting that we created in this scene is probably the most complete one that we have created so far. First of all, we have both the interior and exterior lighting. The exterior is quite similar to the one that we created in Chapter 4, Creating an Exterior Scene. It is a mix of a sky texture and an environment texture plus a sun lamp. In this case, we did not use the sun-position plugin to set everything up, but we rotated the sky, the sun and the textures by hand to achieve the effect that we wanted. It is not as accurate as using the plugin, but we can fine-tune the lighting enough to obtain the effect that we are looking for. 201Creating a Car Animation For the exterior, we also used the SunDisk mesh. This emitter will contribute a lot when we will composite the scene at the end of the chapter. The contribution of this mesh, in terms of pure lighting, is close to zero, but we will see how to turn this into a real sun in the final two recipes of this chapter. Finally, the interior lighting is also quite straightforward. It comprises of a portal light and a series of mesh lights that work as real lights in the room. The portal as not only the camera and the shadow ray visibility are turned off, but also the transmission one, in order to avoid seeing it through the car glass. There's more... The interior lights are created using an array modifier. This kind of modifier allows us to create a large number of meshes from a single mesh. We can also add some variation to the position and rotation of the generated meshes through the settings of the modifier. This method is really good, as it saves a lot of time while creating a big number of similar meshes. See also f There is a great new array modifier under development called advanced array modifier . It will allow a much greater control and fine-tuning over the creation of arrays. Sadly, it is still not available to be officially used, but there are a couple of demonstrations of its use at: http://www.blendernation.com/2012/01/05/advanced-array- modifier/ f There is also the possibility of trying it out using some special build from graphicall, like this one: http://www.graphicall.org/537 For those who do not know what graphicall is, it is a portal where all experimental Blender builds are uploaded for everyone to try. Be aware that these are not official versions reliable for production; but if someone would like to try out a new feature which is still not included in the official version, this is the right place to go Creating a car paint material It is now time to create the material for our car. We already saw in detail how to create a car paint material in Chapter 7, Car Rendering in Cycles, but nothing forbids us to learn about another kind of car paint material 202Chapter 8 Getting ready Let's get started, and select the car mesh. As we can see, there are several material slots already assigned to the mesh. The materials that we will be using for the car mesh that really interest us are just a couple, that is the ones related to car painting, which we will explore in detail. How to do it... We will start by creating the white part of the car paint material. Let's add a new material in the first slot, and name it CarPaintWhite. To create a car paint, carry out the following steps: 1. Mix the default Diffuse BSDF node with an Anisotropic BSDF node using a Mix Shader node with the Fac value of0.5. 2. Using the LayerWeight node's Facing output with a Blend value of0.1 as input for the Fac value of a MixColor node, create a mix of two colors (Color1: RGB: 0.090, 0.090, 0.090 and Color2: RGB: 0.700, 0.940, 1.000) in the MixColor node. Then plug the Color output into the Color input of Diffuse BSDF. Also set the Diffuse BSDF Roughness to1. 3. Add a Fresnel node, and set IOR to1.3. Plug it into the Anisotropic BSDF's Roughness input. Set the color to RGB 0.600, 0.600, 1.000 and Anisotropy to0.5. 4. Mix the two BSDFs with a Glossy BSDF using another Mix Shader node. As with the Fac input, we will use the Layer Weight node's Facing output with a Blend value of 0.3. The Glossy BSDF should go into the second Shader socket. 5. Set the Glossy BSDF color to RGB 0.590, 0.900. 1.000 and the Roughness to0. Also set Mode to Sharp. 6. Frame all the nodes that have been created so far, and name the framePAINT: 203Creating a Car Animation 7. Mix Diffuse BSDF and a Glossy BSDF with a Mix Shader node, with 70 percent of inuence fl for Glossy BSDF. 8. Set Diffuse Color to HSV 0.000, 0.000, 0.360, the Glossy BSDF mode to Sharp and the roughness to8.000. Also set the Glossy Color to pure white. 9. Add a Bump node, and plug it to both the Diffuse and Glossy BSDFs' normal sockets. Set Strength to0.020 and Distance to0.600. Also activate the Invert option. 10. Frame these nodes, and name the frameSCRATCHES. Add a Mix Shader node, and plug into the first Shader socket the output of the PAINT frame, and in the second one the Scratches frame. 11. We will now create the input for this Mix Shader node's Fac value and for the bump node. Add an Attribute node, and putCol in the namespace. Plug it into the RGB Curves node, and set it as shown in the screenshot. 12. Mix the output of the RGB Curves node with Noise Texture using a Color Mix node set to Multiply with a Fac value of1.000. Set Noise Texture Scale to150.000, Details to5.000, and Distortion to1.000. 13. Add an Image Texture node, and load theMetalScratches0040_1_M.jpg file, using the Generated coordinates set the Scale to XYZ 5.000, 5.000, 5.000 using a Mapping node. In the Image Texture node, set the Projection method to Box and set the Blend to0.500. 14. Add an RGB value to the BW convertor after the Image Texture node, and finally mix it with the previous node using another Mix Color node. We will plug the image texture into the Color2 socket, while the previous Multiply node into the Fac value. Finally, we need to set the Color1 socket to HSV 0, 0, 0.5. Leave the mixing method to Mix. 15. Frame all these nodes, and name the frame MASK. 16. Now we need to plug the output of this Mix node into the Height socket of the Bump node and into the Fac value of the Mix Shader node that is mixing the other two frames. 17. Copy the CarPaintWhite material into the material slot number four, and make it a single user. Rename the new material toCarPaintRed. 18. Change the MixColor node's Color2 socket of the Paint Frame Diffuse BSDF to RGB 0.230, 0.000, 0.000. Also change the Anisotropic BSDF node's color to RGB 1.000, 0.250, 0.000 and Glossy BSDF node's color to RGB 1.000, 0.600, 0.260. 204Chapter 8 Now we'll create other parts of the car. The following materials are really basic. Their setup is explained with the screenshot: f Slot 2: CarBlackDetails 205Creating a Car Animation f Slot 3: Car Glass f Slot 5: CarLightsGlass 206Chapter 8 f Slot 6: CarTailLights f Slot 7: CarLightsReflections 207Creating a Car Animation f Slot 8: CarLights How it works... The new car paint material that we created is simpler compared to the one we made for Chapter 7, Car Rendering in Cycles. Here, we do not have flakes, and we did not use the PYLA OSL script as we did then to layer the different material levels (for further details about the script refer to Chapter 7). However, the material that we created is effective for our purpose. We used a combination of anisotropy and glossiness to achieve the right look for the reflections and a base made with Diffuse BSDF. In this version of the car paint, we also used the vertex paint to create a ruined part of the chassis. Finally, we used a Fresnel node to drive the roughness of the anisotropic BSDF. As we are learning, the possibilities offered by Cycles in terms of the creation of shaders are limited only by our imagination The rest of the materials created for the car are really basic. We will see later on in the chapter how to prepare the car model for the animation in order to obtain all the information needed to do a proper composition with it. 208Chapter 8 There's more... For the creation of the car paint, we used the vertex paint as a mask to separate the two different shaders. Moreover, we used the same mask as a source for the bump map, so that we could have zones where the paint has been removed with scratches and so on. See also f Check out the other car paint shaders in the additional materials file that is provided with the book Creating the materials for the exterior environment Let's now take care of the exterior parts of our scene Getting Started We have different interesting techniques to use here. We will see how to create a great-looking rocky cliff, a desert, and some sci-fi structures Let's get started. How to do it... The main piece of the exterior is the cliff rock with the desert on it. Let's select the mesh called Land and add a new material to it. We will call itCliff_Desert. To create the desert environment, we'll carry out the following steps: 1. In the material node editor, let's add two Image Texture and a Texture Coordinates node. LoadSoilSand02.jpg andSoilSand01.jpg using the UV coordinates for them. Mix them using a MixColor node with Fac of0.5 and Mix mode. 2. Add another Image Texture node, and load theSoilCracked.jpg file. Also for this texture, let's use the UV coordinates, and let's set the scale to XYZ 25, 25, 25 using a Mapping node. 3. Mix the last image textures with the mix of the previous two using another Mix Color node with Fac 0.5 and Mix mode. 4. Add a Voronoi Texture node, change the mode to cells, and Scale to600. Multiply the voronoi texture to the previous textures with a Mix node with Fac of0.6. 209Creating a Car Animation 5. Add another Mix Color node, plug the textures into the Color1 socket, and set Color2 to RGB 0.660, 0.160, 0.020. Set the mode to color and Fac to0.600. 6. Finally add an HSV node, and set Saturation to 0.8; then plug it into the Diffuse BSDF node. 7. Frame all the nodes that we created, and name the frame Desert. Let's create the cliffs: 1. Add two Image Textures nodes, and load theAridRocks.jpg andCliff.jpg files. Use the UV coordinates for theAridRocks.jpg image while adding an Attribute node, and use the CliffUVs for theCliff.jpg image. 2. Mix them using a Mix Color node with Fac as1.000 and the Add mode. Put the Cliff.jpg texture into the Color2 socket. 3. Add another Mix Color node, and set it to the Multiply mode. Plug the sum of the two textures into the Color1 socket ,and set the Color2 to RGB 0.1, 0.08, 0.075 and the Fac to0.8. 4. Plug the result of these textures into the Diffuse BSDF color socket and also into an RGB to B node and a Gamma node (with Gamma 1.6), and plug them into a Glossy BSDF Color input. Set the Roughness to0.4. 5. Add the two BSDFs using an Add Shader node. 6. Add two new Image texture nodes and load theRocksArid_height.tiff andRocksArid_normal.tiff files again using the UV coordinates. 7. Also add a Noise Texture node and set Scale to300.000, Detail to2.000, Distortion to0.500, and Add it to theRocksArid_height texture using a Mix Color node with Fac 1.000. For the Noise Texture we want to use the Generated coordinates. 210Chapter 8 8. Plug this last node into the Height socket of a Bump node. Also add a NormalMap node and plugRocksArid_Normals into it. Set Strength to0.5 and plug it into the Normal socket of the Bump node. 9. Set Bump Strength to0.6 and Distance to1 and plug it into the Normal input of Diffuse and Glossy BSDFs. 10. Frame all the nodes that we created and label the frame asCliff. 11. Let's mix the two frames using a Mix Shader node. We will plug the Desert frame into the first socket and the Cliff frame into the second one. 12. As Fac input let's use an Attribute node. Into Name let's writeCol and plug into the Fac socket the Color output. Let's create the metal structure: 1. Select the MetalStructure mesh and add a new material into the first Material Slot. Name itPanelMetal. 2. Mix default Diffuse BSDF with Anisotropic BSDF using an Add Shader node. Set Diffuse BSDF Roughness to1, Anisotropic BSDF roughness to0.2, anisotropy to0.5. 211Creating a Car Animation 3. Add two Image Texture nodes and load theSciFiPanel.jpg andSciFiPanel_ normal.tiff files. We will use the UV coordinates and set the scale to XYZ 5, 5, 5 using a mapping node. 4. Add a Bump and Normal Map node. Plug the Normal map output into the Bump's normal input. Plug the normal map image texture into the Normal Map node and theSciFiPanel image texture into the Height socket of the Bump node. 5. Set Bump Strength to0.1 and Distance to0.5. Also set Normal Map strength to0.1. Plug Bump's normal output into the Diffuse and Anisotropic BSDF's normal inputs. 6. Finally plug theSciFiPanel Image texture color output into the Diffuse and Anisotropic BSDF node's color inputs. Let's create the cupola: 1. Select the Cupola Mesh and add a new material into the first material socket. Name itCupola. 2. Mix the default Diffuse BSDF with a Glossy BSDF using a Mix Shader node. Plug a Layer Weight node's Facing output into the Fac value and set Blend to0.5. Also set Glossy Color to HSV 0, 0, 0.14 and Roughness to0.1. 3. Add an Image Texture node and load theMetalScratches.jpg file. Use the Generated coordinates and set Scale to XYZ 3, 3, 3 using a Mapping node. In the Image Texture node, set the Projection method to Box and the Blend to0.5. 4. Plug the MetalScratches texture into the Color1 socket of a Color Mix node in the Mix mode, with Fac value of0.65. Set Color2 to HSV 0, 0, 0.05. Finally plug the Mix node output into the Diffuse BSDF color input. 5. Add an RGB to BW convertor after the Image Texture node and plug it into a Bump node. Set Strength to0.1 and Distance to0.6. Plug the Bump node into the Normal sockets of the Diffuse and the Glossy BSDF nodes. 212Chapter 8 6. Add a new material into the second material slot and name it CupolaMetal. 7. Mix default Diffuse BSDF with Anisotropic BSDF using a Mix Shader node, with a fac value of0.5. Set Anisotropic roughness to0.2, anisotropy to0.9 and rotation to0. Also set Color to pure white. 8. Add an Attribute node and writeCol into the namespace. Plug the Color output into the Color2 socket of a Mix Color node, in the Multiply mode and a Fac value of0.5. Set Color1 to HSV 0, 0, 0.035. Finally plug it into the Color socket of Diffuse BSDF. Let Color be set by default: Let's create the sea: 1. Select the Sea mesh and add a new material to it. Name itSea. 2. Mix Refraction and Glossy BSDF using a Mix Shader node, with 80 percent influence from Glossy BSDF. Set the Refraction color to white and Roughness 0.02 and IOR to1.333. Set the Glossy color to white and Roughness to0.02. 213Creating a Car Animation 3. Add an Image Texture node and load thedisp_00000.jpg file that you will find in theOcean folder contained in the main textures folder. Click on the drop-down menu where it says Single Image and select Image Sequence. Set Frames to400, Start Frame to0, and Offset to0. Check the Autorefresh option. This process will allow us to use a sequence of images based on the frame that we will be rendering, instead of a single image. 4. For Texture, we will use the UV coordinates, and we will set the scale to XYZ 30, 30, 30 using a Mapping node. 5. Plug Image Texture into the Bump node's Height socket and set Strength to 3 and Distance to1. Finally plug the Bump node into the Refraction and Glossy BSDF's normal inputs: Let's create the bridge structure: f First Material slot: Cement. 214Chapter 8 f Second Material slot: SteelCable. Let's create the road: The image texture file to be used is Road.jpg: 215Creating a Car Animation Let's create the floor: The image texture file to be used is MetalScratches.jpg: How it works... In this recipe, we learned some new, interesting things. The most complex material that we created is the one for the land mesh. Using the vertex paint as a mask, we mixed two really big node groups and smoothly combined them together. As we did in Chapter 4, Creating an Exterior Scene, we are using a displace modifier to obtain the proper displacement as this function is still missing in Cycles. We will see how to optimize this for our animation in the next recipe. Another really interesting material is the one for the sea. For the first time, we used an animated texture in our shader. This is a really useful function that will allow us to use different textures during the animation. As we obviously want the sea to move throughout the time of the animation, an image sequence is the best technique to obtain this effect. To have animated textures, we can also use video sequences, but in general, image sequences will allow us more control. We need to set the total number of frames and the number with which the first image of the sequence is named, which in our case is00000. Finally we can offset the beginning of the image sequence through the timeline in case we want the texture to not be animated from the beginning. There's more... f The image sequence that we used for the sea is obtained from the ocean modie fi r included in Blender. This modie fi r simulates the movement of the sea displacing the surface of a mesh. This is great because it allows us to have a big amount of detail, but it is also quite demanding in terms of hardware. Anyway, thanks to the same modie fi r, we can also bake the sea movement as bump and normal map sequences, which we can later use on a simple plane. Using the last option will result in a much lighter scene, and will be less demanding in terms of hardware and lower render times. 216Chapter 8 See also f Have a look at this tutorial to understand the usage of the ocean modifier better: http://www.youtube.com/watch?v=2V0Q0kDkm9Y Setting up the scene for the animation In this recipe, we will optimize our scene as best as we can in order to decrease the total render time. Getting ready It is better to underline something from the beginning. As we said earlier in this book, rendering can be a quite long story. Rendering an animation is a much longer story. No matter how much we are going to optimize the scene, our rendering is quite heavy, and we have to render 375 frames. With that said, let's get started How to do it... Optimizing the scene means we need to get rid of what is not strictly necessary in a certain moment. It will happen during our animation; something that is really close to the camera and needs a lot of detail in a certain moment will be far away and almost invisible later on. And when the thing is not so close to the camera, it is useless to have the maximum detail possible. We will start by optimizing the heaviest mesh, the Land mesh. Let's optimize the Land mesh: 1. Select the Land mesh and go to the modifier menu. 2. The first modier fi of the list is a subdivision surface one. Right now Render Subdivision is set to5. Let's go to frame number 114 on our timeline and with the mouse cursor placed over the Render Subdivision number, let's press I on the keyboard. The number will become yellow. You can also add a key frame by pressing the right button on the value and clicking on Add Keyframe. 3. Go to frame 113 (the number will become green) and set the subdivision number to 4. With the cursor over it, press I again. 4. Now go to frame 199. The number of subdivisions should again be 5, but they should be green in color. Press I while the cursor is over the number, and it will become yellow again. 217Creating a Car Animation 5. Go to the next frame (200), set the number to 4, and add another key frame by pressing I: 6. Let's go to the sampling panel. While the timeline is set to frame 1, add a key frame to the Seed value. Then go to the last frame (375) and set the Seed value to a value higher then 375; 400 will be good. Add another key frame. 7. Now let's move to frame 199, set Render Samples to400, and add a key frame. Then move to the next frame (200), set Samples to800, and add another keyframe. 8. Set the Clamp value to8. 9. In the Light Paths panel, check the No Caustics option and set the remaining settings as shown in the following screenshot. 10. Check the Motion Blur option and in the panel, set Shutter to0.3. 11. In the Film panel, check the Transparent option. 12. In the Output panel, set Format to OpenEXR and check the RGBA and Float(Half) options: 218