In this chapter, we will cover the following topics:
Unity 5 introduces in new Physically-Based Shaders. Physically-Based Rendering is a technique that simulates the appearance of materials based on how the light reacts with that material (more specifically, the matter from which that material is made) in the real world. Such a technique allows for more realistic and consistent materials. So, your creations in Unity should look better than ever. Creating materials in Unity has also become more efficient now. Once you have chosen between the available workflows (Metallic or Specular setup; we'll get back to that later), there is no longer the need to browse the drop-down menus in search of specific features, as Unity optimizes the shader for the created material, removing unnecessary code for unused properties once the material has been set up and the texture maps have been assigned.
For a deep understanding of Physically-Based Rendering, we recommend you to take a look at The Comprehensive PBR Guide, written by Wes McDermott from Allegorithmic, freely available in two volumes at http://www.allegorithmic.com/pbr-guide. Allegorithmic's guide contains invaluable information on PBR theory and techniques, having been a fundamental reference for this chapter. A great resource that we'd recommend you take a look at is Mastering Physically Based Shading in Unity 5 by Renaldas Zioma (Unity), Erland Körner (Unity), and Wes McDermott (Allegorithmic), available at http://www.slideshare.net/RenaldasZioma/unite2014-mastering-physically-based-shading-in-unity-5.
Another resource is Physically Based Shading in Unity by Aras Pranckevičius (Unity), available at http://aras-p.info/texts/files/201403-GDC_UnityPhysicallyBasedShading_notes.pdf.
The visual aspects of a material can be modified through the use of textures. In order to create and edit image files, you will need an image editor such as Adobe Photoshop (the industry standard, and has its native format supported by Unity), GIMP, and so on. In order to follow the recipes in this chapter, it's strongly recommended that you have access to a few pieces of software like these.
When saving texture maps, especially the ones that have an Alpha Channel, you might want to choose an adequate file format. PSD, Photoshop's native format, is practical for preserving the original artwork in many layers. The PNG format is also a great option, but please note that Photoshop doesn't handle PNG's Alpha channel independently of the transparency, possibly compromising the material's appearance. Also, PNG files don't support layers. For this chapter, we will often use the TIF format for three main reasons: (a) it's open to those not using Photoshop; (b) it uses layers; (c) it preserves the Alpha Channel information. The file size is significantly greater than in PSDs and PNGs, so feel free to save your work as PSDs (if you have Photoshop) or PNGs (if you don't need layers and, if using Photoshop, Alpha Channels).
Finally, a word of advice - although it's possible to manually create texture maps for our materials by using the traditional image editing software, new tools such as Allegorthmic's Substance Painter and Bitmap2Material make this work much more efficient, complete, and intuitive, complementing the traditional texture-making process or replacing it altogether - in a similar way to what zBrush and Mudbox did for 3D modeling. For design professionals, we strongly recommend at least trying such tools. Note, however, that products from Allegorithmic won't make use of Unity's Standard Shader, relying on the substance files (which are natively supported by Unity).
To understand the new Standard Shaders, it's a good idea to know the workflows, their properties, and how they affect the material's appearance. There are, however, many possible ways to work with materials - texture map requirements, for instance, might change from engine to engine, or from one tool to another. Presently, Unity supports two different workflows: one based on Specular, and another based on Metallic values. Although both workflows share similar properties (such as Normal, Height, Occlusion, and Emission), they differ in the way the diffuse color and reflectance properties are set up.
Unity's Standard Shader (Specular setup) uses Albedo and Specular/Smoothness maps, combining them to create some of the material's aspect—mainly its color and reflectance qualities. The following shows the difference between Albedo and Smoothness maps:
To illustrate such concepts, we have created a battery object (shown below), featuring brushed metal caps and a plastic body. Observe how each map contributes to the final result:
Unity's default Standard Shader combines Albedo and Metallic/Glossiness maps to create the color and reflectance qualities of the material. The following are the differences:
To reproduce the battery that illustrated the Specular workflow by using the Metallic workflow, maps would have to be recreated as follows:
It's also worth mentioning that Unity's Standard Shaders support other maps such as:
Before you start, it might be a good idea to read Unity's documentation on textures. It can be found online at http://unity3d.com/support/documentation/Manual/Textures.html.
Finally, Unity has put together a great resource for those looking for some pointers regarding how to set up maps for a variety of materials: the Shader Calibration Scene, which can be downloaded (for free) from the Unity Asset Store. It is a fantastic collection, featuring sample materials (both Metallic and Specular setup) for wood, metal, rubber, plastic, glass, skin, mud, and much more.
3.139.239.41