Materials, shaders, and textures

Okay, now we have seen how Unity renders a scene and the various draw modes available. However, we still need to go over how an object is colored or textured. In Unity, we typically use materials, shaders, and textures to render 3D objects. A material is essentially an encapsulation of a shader, its dependent textures, and other settings. Let's see what AndyMaterial looks like in Unity by following the given steps:

  1. Open the Assets/GoogleARCore/HelloARExample/Materials/Andy folder in the Project window and select AndyMaterial. Look at the Inspector window and note the name of the Shader (ARCoreDiffuseWithLightEstimation) at the top. The current Shader uses a simple lighting model and has been optimized for mobile AR, which we don't currently need, so we will change it.
  2. Expand the Shader dropdown in AndyMaterial and select Standard. This will switch the material to using the Standard Shader, as shown in the following screenshot:
Switching Andy to use the Standard Unity shader
  1. The first thing you will immediately note is that Andy gets very dark. This is because the Metallic and Smoothness are turned way up. Use your mouse to adjust the various values to something more pleasant, as shown by the red arrows in the preceding screenshot. Perhaps a metallic shiny Andy?
One thing to note when adjusting materials is that any changes you make to a material will be automatically saved and persisted even when running in the play or demo mode. Sometimes, it is useful to have backups of settings, especially if you found them difficult to achieve.
  1. Make a copy of AndyMaterial by selecting it in the Project window and typing Ctrl + D or command + D on Mac. Rename the new material StandardAndyMaterial.
  2. Select AndyMaterial again. Change Shader back to ARCore/DiffuseWithLightEstimation. Note how the look of Andy quickly changes.
  3. From the menu, select File | Save Scenes. Save the scene to the Assets/GoogleARCore/HelloARExample/Scenes folder as RenderingTest.scene.

As you can see, there are plenty of options and settings that can go into rendering a 3D object. Feel free to explore on your own what each of the material settings are on the Standard Shader. In the next section, we will expand our understanding of rendering by discussing lighting.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.151.45