Chapter 7: Shader Buffet

OVERVIEW

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 takes to compute it. For example, if you're already computing specular, you've done all the work required to compute a diffuse color as well, except for the actual color modulation. The most important thing to do is to think of these techniques as a palette from which to artistically create your objects, rather than a cookbook from which you can choose only a single recipe.

There are many instances where you will reuse the same instructions; for example, local lights vs. infinite lights will make you go through the same calculations for both the specular term and the diffuse term. In the buffet, I'll present one shader that uses a local light, another that uses a directional one. Since the only difference will be in how the light direction vector is calculated, I assume that once you've decided what type of light you want for a shader, you'll be able to cut and paste to get the correct vector for that light type.



Real-Time Shader Programming(c) Covering Directx 9. 0
Real-Time Shader Programming (The Morgan Kaufmann Series in Computer Graphics)
ISBN: 1558608532
EAN: 2147483647
Year: 2005
Pages: 104
Authors: Ron Fosner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net