Appendix D. Shaders and Cg/HLSL Programming
This appendix presents a brief overview of the structure of surface shaders and Cg/HLSL programming.
Shaders in Unity can be written in one of the following three different ways:
- Surface shaders will probably be your best bet. Write your shader as a surface shader if it needs to interact properly with lighting, shadows, projectors, and so on. Surface shaders also make it easy to write complex shaders in a compact way—it's a higher level of abstraction. Lighting for most surface shaders can be calculated in a deferred manner (except for some custom lighting models), which allows your shader to efficiently interact with many real-time lights. You write surface shaders in a couple of lines of Cg/HLSL and ...