O'Reilly logo

Unity Shaders and Effects Cookbook by Kenny Lammers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a CgInclude file to store lighting models

Knowing about the built-in CgInclude files is great, but what if we wanted to build our own CgInclude files to store our own lighting models and helper functions? We can in fact create our own CgInclude files, but we need to learn a little more code syntax before we can start to use them efficiently in our Shader writing pipelines. Let's take a look at the process of creating a new CgInclude file from scratch.

Getting ready

Using the same scene, Shader, and Material, let's walk through the process of generating a new item for this recipe.

  1. Begin by creating a new text file and call it something like MyCgInclude.txt.
  2. Then change its file extension to .cginc. Windows will give you a warning message saying ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required