CHAPTER 7

SHADER BUFFET

I’m not going to take the usual route that you see in these shader collections. Instead, I’m going to do it building-blocks style, that is, I’ll give you, say, a variety of diffuse shaders and a variety of specular ones. You get to mix and match. I want to impart the fact that you can create and use these in any way you want; there’s no right or wrong way. Once you understand how a Lambertian diffuse term behaves, you’ll know those situations when you want that effect, and you can take the snippet of code that allows you to do Lambertian. If you want some specular, you can choose between Phong, Blinn–Phong, Schilck, Cook–Torrance, etc.

This way, you’ll recognize the individual traits of each piece of code and what it ...

Get Real-Time Shader Programming 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.