How it works...

When a shader wants information about its surroundings, it is usually provided in a structure called cube maps. They have been briefly mentioned in Chapter 2, Creating Your First Shader, as one of the shader property types, among Color, 2D, Float, and Vector. Loosely speaking, cube maps are the 3D equivalent of 2D textures; they represent a 360-degree view of the world, as seen from a center point.

Unity previews cube maps with a spherical projection, as seen in the following diagram:

When cube maps are attached with a camera, they are referred to as skyboxes, as they are used to provide a way to reflect the sky. They can be ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.