How to make snow in Blender 3D

how to make 3d snow globe card and how to do 3d snowflakes and how to make a 3d snowman and how to make a 3d snow globe on a door
Dr.MohitBansal Profile Pic
Dr.MohitBansal,Canada,Teacher
Published Date:26-10-2017
Your Website URL(Optional)
Comment
Creating an Iceberg Scene We will cover the following recipes in this chapter: f Creating the ice and snow materials f Creating the sea material in Cycles f Compositing the scene Introduction In this chapter we will see how to create snow and ice material, and how to mix them together according to the position of the mesh. These two materials will be quite complex and will make use of many of the techniques we have learned until now. From now on we will focus more on the creation of the materials, as the lighting will be the same as the one we already created several times.Creating an Iceberg Scene Creating the ice and snow materials In this recipe we are going to create all the material for an iceberg. Our target is to have snow on the flat surfaces and ice on the slopes, where it is too steep for the snow to stay. Let's get started Getting ready We will create the ice and the snow using a single material, and mix them using a new technique. Select the iceberg mesh and add a new material to it. How to do it… We will now see the steps required to create the ice as well as the snow material. Creating ice The following are the steps to create ice: 1. Add Glossy BSDF and Glass BSDF and mix them using a Mix Shader node. Let's put Glossy in the first socket and Glass in the second one. 2. As input for the color of both the BSDFs, we will use a color Mix node with Color1 as white and Color2 as RGB 0.600, 1.00, 0.760. 3. As input for the Fac value of the color Mix node, we will use a Voronoi Texture node with the Generated coordinates, Intensity mode, and Scale 100. Invert the color output using an Invert node and plug it into the Fac value of the color Mix node. 4. As the input for Roughness of the Glossy BSDF, we will use the Layer Weight node's Facing output with a Blend value of0.800. Then we will plug this into a ColorRamp node and set the color stops as shown in the following screenshot. The first color stop is HSV 0.000, 0.000, 0.090 and the second one is HSV 0.000, 0.000, 0.530. Remember to plug the ColorRamp node into the Glossy BSDF roughness socket. 228Chapter 9 5. Finally, set Glass BSDF node's IOR to1.310 and Roughness to0.080. 6. Now we will create the Fac input for the Shader Mix node of the two BSDFs. Now we will add Noise Texture to the Generated coordinates with a Scale of130, Detail of1, and Distortion of0.500. Plug this into a ColorRamp node and set the color stops as shown in the the following screenshot. 229Creating an Iceberg Scene 7. Let's now add a Subsurface Scattering node. Set the mode to Compatible, the Scale to10.000 and the Radius to 0.070, 0.070, 0.10. 8. As a color input, let's add another color Mix node with Color1 as RGB 0.780, 0.960, 1.000 and Color2 as RGB 0.320, 0.450, 0.480. 9. The Fac input for the color Mix node will be the same as for the color Mix node of the Glass and Glossy BSDFs. Now mix the SSS node with the mix of the other two BSDFs, using an Add Shader node. 10. Now, we will create the normals for the shader. Add three Image Texture nodes. In the first one, let's load the IceScratches.jpg file. We will use the Generated coordinates with a Scale of XYZ 20.000, 20.000, 20.000. Set the projection mode to Box and the Blend to0.500. 11. In the second Image Texture node, load theice_snow_DISP.png file, using the UV coordinates. 12. Finally, load theice_snow_NRM.png file in the third Image Texture node, using again the UV textures. 13. Now let's mix theIceScratches.jpg with theice_snow_DISP.png textures, using a color Mix node with the Displacement Texture into the Color1 socket and the scratches texture into the Color2 socket. Set the Fac value to0.100. 14. Plug the mix of the textures into the Height socket of a Bump node and then plug the ice_snow_NRM.png texture into the Color socket of a Normal Map node. Finally, plug this one into the Normal socket of the Bump node. 15. Set the Normal Map node's Strength to0.050, the Bump node's Strength to0.500 and the Distance to1.000. 16. Plug the Bump node into all of the BSDFs we added so far. 17. Frame every node we created and label the frameICE. 230Chapter 9 Creating snow 1. The nodes we will add now will still be within the same material, but outside the ICE group we just created. Add a Glossy and a Subsurface Scatter BSDF nodes. Mix them using a Mix Shader node with 20 percent of influence from the Glossy BSDF node. 2. Set both the colors to white. Also, set the SSS Scale to3.00 and the Radius to 0.400, 0.400, 0.450. Set the Glossy mode to GGX and the Roughness to0.600. 3. Add a Noise Textures node and set Scale to2000.000, Detail to2.000 and Distortion to0.000. We will use Generated coordinates for this texture. 4. Connect the Fac output of the Noise Texture node to the Height socket of the Bump node and set the Strength to0.200 and the Distance to1.000. Connect the Normal output of the Noise Texture node to the Normal input of the Subsurface Scatter BSDF and Glossy BSDF nodes. 5. Now let's mix the Mix Shader node of the Subsurface Scatter BSDF and Glossy BSDF nodes with an Emission shader using another Mix Shader node. 6. Add new Noise Textures, this time with Scale as2500.000, Detail as2.000, and Distortion as0.000. 7. Connect the Fac output of the Noise Texture node to the Color input of the Gamma node, with a Gamma value of8.000, and then add the Color output of the Gamma node to the Fac input of the ColorRamp node. We will set up the color stops as seen in the next screenshot. 8. Connect the ColorRamp node's Color socket to the Fac socket of the previous Mix Shader node. Remember to use the Color output of the ColorRamp node. 9. Frame all these nodes and label the frameSNOW. 231Creating an Iceberg Scene Mixing ice and snow 1. Add a Geometry (Add Input) and a Normal node (Add Vectors). Connect the Normal output from the Geometry node to the Normal input of the Normal node. 2. Now connect the Dot output of the Normal node to the first socket of a Multiply node and set the mode to Multiply and the second value to2.000. 3. Add a Mix shader node and connect the ICE frame into the first Shader socket and the SNOW frame into the second one. Finally, connect the output of the Multiply node into the Fac value of the Mix Shader node. 232Chapter 9 How it works... Let's see the most interesting points of this material in detail. For the ice material, we used a Voronoi Texture node to create a pattern for the surface color. Then we mixed the Glass and Glossy BSDF nodes using a Noise Texture node to simulate both, the more and less transparent areas: for example, the ice may be less transparent due to some part of it being covered with snow, difference in purity of the water, or the thickness of the ice. Then we mixed the two BSDFs with a Subsurface Scatter node to simulate the dispersion of the lighting inside the ice. Note that we used the ColorRamp node quite often in order to fine tune the various mixing and inputs. The snow material is quite similar for the main concept, but is missing the refractive part of the ice. Here we did something else. We used a Noise Texture node with some tweaking (Gamma and ColorRamp) to make it really contrasted to mix an emission shader to the rest of the material. This will create a small emission dot over the snow surface that we will use in compositing to create the flakes. It is really interesting how we mixed the two materials. We wanted the snow to be placed only on the flat surfaces of the iceberg, while we wanted the slopes to be just ice. To obtain this effect, we extracted the normal information about the mesh and used it to understand which part of the mesh is facing upward. We must imagine the normals to be working like the sunlight falling on the surface of the earth. Half of the sphere is in darkness, and half is hit by the light. We can decide from which direction the light hits the surface. Now imagine the same principle applied to the shape of our mesh. In this way we can create a white mask on the areas that are hit by the normal sphere direction. With the Normal node, we can orient this effect wherever we want. The default position of the sphere is exactly what we needed: the parts of the mesh that are faced upward are made white, while the rest of the mesh is black. Turning the sphere around will make the direction of the ramp that has been created, change accordingly. 233Creating an Iceberg Scene The sphere, maybe, is not the best way to set these kind of things as it lacks a bit of precision (as for the setting of the sky), but this will probably change in the future with something that allows more precise settings. Finally we used a Multiply node to multiply the value coming from the Normal node and increased the contrast of the mask. There's more... The normal method we just saw in this recipe is not the only way of mixing materials. Just some time ago, two new plugins have been developed. The first one allows us to obtain the same results we got in this recipe by creating a weight map or a vertex paint based on the slope of the mesh, while the second creates the same based on the altitude. This opens up many possibilities not only in terms of material creation, but also for the distribution of particle systems The plugins can be downloaded from the following links, where we can find some instructions about them: http://blenderthings.blogspot.nl/2013/09/height-to-vertex-weights- blender-addon.html See also In the following link, Andrew Price teaches us how to create a different kind of ice material; for example, material that is more suitable for ice cubes. Surely worth a watch f http://www.blenderguru.com/videos/how-to-create-realistic-ice/ Creating the sea material in Cycles Although we've already created some sea material, this one is going to be something new. While the other sea materials were just a mix of reflective and refractive shaders, now we are going to try to mimic a real mass of water, where the color and the roughness of the refraction changes with the change of the depth. To obtain such an effect in computer graphics the most useful thing would be volumetrics. This, for now, is not yet implemented in Cycles, so we will have to fake it. Anyway, as we've already learned, cheating is quite normal while creating 3D graphic scenes, and the result will be great anyway Let's get started. Getting ready Select the sea mesh and add a new material to it. Name itsea. 234Chapter 9 How to do it… To create the sea material, follow the ensuing steps: 1. Let's add a Refraction BSDF node and a Glossy BSDF node and mix them together using a Mix Shader node, with Refraction to the first socket and the Glossy to the second one. As input for the Fac socket, we will use a Fresnel node with IOR 1.120. 2. Let's set the Refraction node's IOR to1.333 and the Glossy node's Roughness to 0.005. Also set the Glossy color to white. 3. Now we are going to create the input for the Refraction BSDF roughness. Add a Camera Data node (Add Input) and a Multiply node. Connect the camera data View Distance output to the first Value socket of the Multiply node. Set this to the Multiply mode and set the second Value to0.001. 4. Finally, connect the Multiply node to the Roughness socket of the Refraction BSDF node. 5. Now it's time to create the sea bump. Add a Noise Texture node to a Wave Texture node using a Mix color node in the Add mode. Set the Wave Texture node's Scale to 30.000, Distortion to14.000, Detail to4.000, and Detail Scale to2.000. Then, set the Noise Texture node's Scale to400.000, Detail to2.000, and Distortion to 0.000. Finally, set the Mix color node's Fac value to1.000. 6. Add a Voronoi Texture node in the Intensity mode and multiply it to the sum of the two previous textures. Set the Fac value of the Mix node to0.400. Also, set the Voronoi Texture node's Scale to400.000. 7. Connect the previous Mix node to the Height socket of a Bump node. Set Strength to 0.250 and Distance to1.000. Finally, connect the Normal output to all the Normal inputs of the BSDFs. 8. Now we want to create some fake water-like caustics. Add another Voronoi Texture node and set Scale to200.000 and the mode to Intensity. Connect the Fac output from the Voronoi Texture node to an Invert node. 9. Then add a ColorRamp node after the Invert node and set the interpolation mode to Constant. Set the color stops as shown in the following screenshot. After the ColorRamp node, add a Math node and set it to Multiply. Set the second socket's value to5.000. 10. Connect the Math node to a Transparent BSDF node. Mix the Transparent BSDF node with the mix of the other two BSDFs using a Mix Shader node. Make sure the Transparent BSDF node is connected to the lower socket. 235Creating an Iceberg Scene 11. Finally, add a LightPath node and connect the Is Shadow Ray to the Fac value of the Mix Shader node. How it works... Let's understand the most important things about this sea material. Surely, even if it is quite simple, the most interesting thing is how we achieved a variable roughness for the Refraction BSDF node. The Camera Data node, as the name says, gives us information about the camera. We need information about the distance of the shading point from the camera. We can use View Z Depth of View Distance. The difference between the two is that, the first one gives a constant distance from the plane, which is perpendicular to the view vector of the camera. The second one returns the distance exactly from where the camera rays are shot, which is the camera itself. It is important to note that while we are in real-time preview mode, the distance is calculated from the point from where we are looking at the scene, even if this point is not the camera. Of course, while rendering, this point can only be the active camera of our scene. As we said at the beginning of the recipe, this method is not accurate, and for our purpose, can work only for a still image. Anyway, the effect that we can get is enough for our purpose. Using View Distance, we can create some sort of a depth spherical map around the camera. 236Chapter 9 This means that the roughness will increase not only with the depth, but also with the distance from the camera over the water surface. This last thing is not exactly what we want, but from our camera's point of view, it will not be a big problem. After this we created a bump using a combination of procedural textures and some fake caustics, using the method we learned in Chapter 2, Creating Different Glass Materials in Cycles, with the addition of a Voronoi Texture node to generate the initial pattern. There's more... As said at the beginning of the recipe, the correct way to achieve the variable roughness in the water would be through volumetric, which at the moment, is still not supported in Cycles. Anyway, as I am writing these words, there are already experimental builds on Graphicall that contain a very early version of the volumetric shading. For those who would like to play a bit with them, I advise you to download the builds released by Tungers under the name GSoC 2013— DingTo (Google summer of code). For example, this one:http://graphicall.org/1049. See also This thread on Blender artists (also in the following pages) has the first experiments with the volumetric in Cycles. There are some interesting node setups, tips, and tricks to pick up f http://blenderartists.org/forum/showthread.php?216113-Brecht-s- easter-egg-surprise-Modernizing-shading-and-rendering/page650. 237Creating an Iceberg Scene Compositing the scene It is time to make some quick compositing to our scene to give the final touch. Apart from the background and some other minor things, it will be important to make the snowflakes sparkle, as they ideally should. Let's see how Getting ready Before we render the scene, we need to activate the Emission passes from the Render Layers panel. How to do it... Let's go to the node compositor and get started. We will start by compositing our image over the background. 1. Connect the Alpha output from the Render Layer node to a Dilate/Erode node (Add Filters). Set the mode to Feather and Distance to-7. 2. After this, add a Blur node; set it to Fast Gaussian and set the Strength toX: 5,Y: 5. Connect the Blur node to an Invert node. 3. Add a Mix node, and connect the Alpha output from the Render Layer node into the Fac value and the output from the Invert node into the lower Image socket. Set the upper Image socket to black. Label the Mix node HorizonMask. 4. Copy the Dilate/Erode node and the Invert nodes. Again, connect the Alpha output from the Render Layer node to the Dilate/Erode node and set the Distance to-30 and then connect this to the Invert node. Plug its output into the Fac socket of a new Mix node and plug the Environment output from the Render Layer node into the lower Image socket. Set the first Image socket to RGB 0.58, 0.62, 1. Label the Mix nodeSky. 5. Add an Alpha Over node (Add Color) and plug the Image output from the Render Layer node into the lower socket and the Environment output into the upper one. 6. Add another Mix node and set it to the Add mode. Connect the HorizonMask Mix node into the Fac socket, the output of the Alpha Over node into the upper Image socket and the Sky Mix node into the lower one. 238Chapter 9 7. Frame all the nodes we have created so far and name the frameBackground. 8. Add a Glare node after the Background frame and set the mode to Fog Glow and the quality to High. Also set Mix to1.000, the Threshold to0.400 and the Size to9.000. 9. Mix this with the output of the Background node using a Mix node; set to the Add mode. Make sure the Glare node goes into the lower Image socket and set Fac to0.600. 10. Add a ColorRamp node after the Emission output of the Render Layer node and set the color stops as shown in the following screenshot. After this, add another Glare node in the Streaks mode. Set the quality to High, Iterations to4.000, Color Modulation to0.550, Mix to1.000, Threshold to0.200, Streaks to7.000, Angle Offset to0.000, and Fade to0.940. 239Creating an Iceberg Scene 11. Connect this to the lower Image socket of a Mix node in the Add mode, and connect to the upper Image socket to the previous Add node. Set Fac to2.500. 12. Add a Color Balance node after the last Add node and set the Lift to white, the Gamma to RGB 0.77, 0.84, 0.84, and the Gain to 1.11, 1.04. 0.96. How it works... The compositing we created here is quite simple. First, we composited the render over the background, creating a mask over the edge of the geometry to mix the background and the render in a better way. To achieve this effect we used a Dilate/Erode node for increasing the size of the Alpha output a bit, then blurred it and finally cut out the Alpha channel again to obtain only a small mask at the edge of the render. After this we created the snowflakes using the Emission output. We increased the contrast as much as we could using a ColorRamp node and then applied a Glare filter. In order to make the flakes more visible, we used a value higher than 1 for the Add node Fac value. There's more... We can increase the size of the horizon mask by decreasing the value of the Dilate/Erode node, blur it more, or decrease its intensity by putting a ColorRamp node right before the Add node and make the white color stop a shade of gray. See also In Blender, it is also possible to create masks manually, which can then be used in compositing, or in many other ways. This link has a tutorial that will show how a mask can be created and used in compositing, plus a lot of other useful things to learn f http://www.youtube.com/watch?v=RBTwXdcLL-M. 240Creating Food Materials in Cycles We will cover the following recipes in this chapter: f Creating grapes in Cycles f Creating parmigiano cheese f Creating bread f Learning the Branched Path Tracing render Introduction In this final chapter, we are going to learn how to create some tasty food. Achieving believable organic materials is quite challenging, and we are going to use most of the techniques we learned so far.Creating Food Materials in Cycles Creating grapes in Cycles We will start out by creating the material for the grapes. For this purpose, we will be using an OSL (Open Shading Language) that we also used in Chapter 7, Car Rendering in Cycles, to realistically layer different shaders. The plugin is the PYLA and you can n fi d it inChapter 7 lfi es. Getting ready Let's select the grape mesh and add a new material to it. Name itGrapes. Then let's move to the material node editor. How to do it… 1. Let's add a SubsurfaceScatter BSDF node. Set the mode to Compatible, Color to RGB 0.66, 0.68, 0.12, and the Scale value to0.6. Also, set the Radius value to 0.6, 0.7, 0.3. 2. Add a Diffuse BSDF node and a Glossy BSDF node, mix them using a Mix Shader node, and make sure the Glossy BSDF node is plugged into the lower socket. Set Glossy Color to RGB -.24, 0.3, 0.98 and the Roughness value to0.04. Also, set the mode to GGX and theDiffuse node's Roughness value to1. 3. Add a Noise Texture node and set the Scale value to5, Detail to2, and Distortion to0.4. Plug this into a ColorRamp node and set the color stops, as shown in the following screenshot. Finally, plug the color ramp into the Fac socket of a Color Mix node and set Color1 to RGB 0.43, 0.5, 0.275 and Color2 to RGB 0.65, 0.65, 0.65. Plug the Color output into the Color input of the Diffuse BSDF node. 242Chapter 10 4. Also, plug the ColorRamp output from the Noise Texture node into the Fac socket of the Mix Shader node. 5. Add a script node (Add Script) and load thePYLA.py file. Plug the SSS BSDF node into the Base socket and the mix of the other two BSDFs into the Layer socket. 6. Set the Opacity value to1, the Depth value to2.5, Fresnel to0.4, IOR to1.333, Mask Layer to0.9, and SecondaryLayer to1. 7. Add another Noise Texture node and set the Scale value to6.6, the Detail value to 2, and the Distortion value to0. Again, we will use UV coordinates. Plug the texture into a ColorRamp node and set the color stops, as shown in the following screenshot. 8. Add another PYLA script node, plug the previous PYLA node output into the Base socket, and the Color Ramp node from the previous Noise Texture node into the Opacity socket. 9. Add a Diffuse BSDF node, set the Roughness value to1, and Color to RGB 0.25, 0.18, 0.08. Plug it into the Layer socket of the PYLA node. How it works... Once again, the usage of the PYLA plugin was really useful for us to get the right look for our material. A real grape is made of different levels—the inside and the skin. We recreated the inside using a Subsurface scattering BSDF node, and then used the PYLA OSL node to realistically layer the other BSDF that we used to recreate the skin. Using a Noise Texture node, we gave some color variation to the skin. 243Creating Food Materials in Cycles Finally, we used another Diffuse BSDF to add some burnt and dirty part over the grape skin. For a normal Mix Shader node, we could use Texture as the mixing factor of the two layers. This of course can be done for each of the sockets of the PYLA OSL node. There's more... Since the coordinates we used for the textures in this material are UV, the pattern among the different berries of the grape will be the same. There is an easy way to give some further variation. We can create a second UV layer for the grapes and just click on unwrap. This will create a new UV set that will be different for each one of the berries. Now in the material, we can use an Attribute node to use the new UV layer with some of the textures and give variation among the grapes. Notice that the scale of the new UV layer is much smaller compared to the r fi st layer, so we will have to adjust the scale of the textures accordingly. In the following screenshot, there is an example of how we could set up the material using this method. See also f In the following link, there is a nice topic about the creation of the material for a red grape using handmade textures, which is really interesting:http:// blenderartists.org/forum/showthread.php?283157-Grapes-SOLVED. Creating parmigiano cheese Now, let's see how to create the material for the parmigiano cheese. This time, we will not be using the PYLA script, but again, there will be SSS in the shader node setup, as this shader is really useful for the creation of organic materials such as food. Getting ready Select the parmigiano mesh and add a new material to it. Name itParmigiano. How to do it… 1. Add a Subsurface Scatter BSSRDF node and set the mode to Cubic. Set the Scale value to1.2, the Radius value to 0.12, 0.12, 0.1, and the Sharpness value to0.4. 2. Duplicate the SSS BSDF node and mix it with the previous one using an Add Shader node. 244Chapter 10 3. Add a Glossy BSDF node, set the mode to GGX, and the Roughness value to0.3. Add it to the sum of the two SSS BSSRDF nodes using another Add Shader node. 4. Add an Image Texture node using UV coordinates and loadParmigiano_cavity. tga. Add a ColorRamp node after the texture and set the color stops as shown in the following screenshot. Also, set the interpolation mode to ease. 5. After the ColorRamp node, add a Mix Color node, set the mode to Multiply, and the Fac value to0.2. Set Color1 to RGB 0.5, 0.39, 0.295 and plug the output of the Color Ramp node into the Color 2 socket. 6. Plug the Mix Color output into the two SSS BSDF nodes' color input sockets. 7. Duplicate the Mix Color node and again plug into the Color2 socket the output from the ColorRamp node. Set Color1 to RGB 0.12, 0.11, 0.1 and the Fac value to0.8. Plug the output into the Color input socket of Glossy BSDF nodes. 8. Add a Noise Texture node, set the Scale value to150, Detail to3, and Distortion to 1. For this texture, we will use Generated coordinates. 9. Add a ColorRamp node after the Noise Texture node and set the color stops as shown in the following screenshot. 10. Add an Image Texture node with UV coordinates and loadParmigianoDISP.tga. 11. Add a Color Mix node, set the mode to Multiply, and the Fac value to1. Plug into the Color1 socket theParmigianoDISP.tga image texture, and in the Color2 socket, the output of the ColorRamp node coming from the Noise Texture node. 12. Add another Color Mix node in the Multiply mode and set the Fac value to1 after the previous one; plug the latter into the Color1 socket while plugging the ColorRamp node from theParmigiano_cavity.tga image texture into the Color2 socket. 13. Add a Bump node and plug the last Multiply node into the Height socket. Set the Strength value to0.4 and the Distance value to1. 245Creating Food Materials in Cycles 14. Add another Image Texture node with UV coordinates and load the ParmigianoDISP_normal.tga file. Plug it into a Normal Map node and then plug this into the Normal Input socket of the Bump node. Set the Normal Map Strength value to0.4. 15. Finally, plug the Bump node output into the input of each one of the BSDFs we have added so far. 16. Frame all the nodes we added so far and label the frame Inside. 17. Add a Subsurface Scatter BSDF node, set Color to RGB 0.35, 0.3, 0.19, the Scale value to0.6, and the Radius value to 0.12, 0.12, 0.1. Also, set the mode to Compatible. 18. Add a Glossy BSDF node, set Color to RGB 0.18, 0.16, 0.08, and the Roughness value to0.05. Also, set the mode to GGX. 19. Mix the two BSDFs using an add shader and then plug the output into the lower socket of a Mix Shader node while plugging the output of the frame labeled Inside into the upper socket. 20. Add an Attribute node and writeCol into the namespace. Plug the Color output into a ColorRamp node and set the color stops as shown in the following screenshot. 21. Finally, plug the ColorRamp output into the Fac input of the Mix Shader node. 246