Making your shader world modular with CgInclude
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 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.
Begin by creating a new text file and call it something like
MyCgInclude.txt
.Then change its file extension to
.cginc
. Windows will give you a warning message saying that the file may become unusable, but it will still work.Import this new
.cginc
file to your Unity project and let it compile. If all goes well, you will see that Unity knew to compile it to a CgInclude file.
We are now ready to begin creating our own custom CgInclude code. Simply double...