Making your shader world in a modular way with CgInclude
Knowing about the built-in CgInclude files is great, but what if we want 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 using 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
Let's walk through the process of generating a new item for this recipe:
- From the
Projecttab, right-click on theAssetsfolder and selectShow in Explorer. You should see your project folder. Then create a text file by right-clicking and selectingNew | Text Document:

- Rename the file to
MyCGIncludeand replace the.txtfile extension with.cginc:

- Windows will give you a warning message saying that the
File may become unusable, but it will still work. - Import this new
.cgincfile into your Unity project and let it compile...