Material textures, lighting, and shaders

Previously, we introduced the use of Materials that can be attached to objects to determine how they look when rendered in the scene.

An object can have a relatively simple 3D mesh-a set of points connected into triangles that define the outward-facing surface shape of the object. Mapping an Albedo texture onto the mesh surface gives the impression of it having much more detail than the mesh itself provides. This is a critical technique for making detailed shapes with less than a hundred triangles, for example, instead of hundreds of thousands, and saving the amount of processing needed by orders of magnitude.

Shaders are the code that runs in the GPU to render objects using their materials, textures, and lighting properties. Unity's standard shader is quite advanced and optimized. In addition to an Albedo texture, you can specify Normal Map, Height Map, and Occlusion Map, which further allow more realistic-looking surface and physically based shading (PBS), in addition to reflective Metallic properties. The following is an example material for a realistic wooden table:

Unity also allows you to place a variety of light sources anywhere within your scene, including Directional lights, Point lights, Spotlights, and Area lights. Lights can vary in intensity, hue, and other properties. Lights can also cast shadows.

Depending on your application, these nice material and lighting features may or may not be very important in augmented reality. For example, if you're building a technical training manual and your AR art style is more illustrative, then simple flat shading may be sufficient. On the other hand, if you're objective is to render objects that look like they're occupying the room with you and belong there, you may want to make them look as realistic as possible. Unfortunately, there is a lot of rendering performance overhead using soft shadows and shadow cascades, so these are best to be avoided on mobile devices and the HoloLens.

As mentioned in Chapter 1, Augment Your World, a current challenge in AR is trying to match the lighting and shading of virtual objects with the actual lighting situation in real life. The Apple ARKit, for example, provides a component we can add to the light source in the scene to adjust its parameters when trying to match the lighting conditions of the real-world room.
..................Content has been hidden....................

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