In the last chapter we got our torus mesh rendering with perspective, but we still don’t have a great way of coloring the surface of it. We can’t take the easy way out and slap a texture on it, because we don’t have a texture, and the UVs on our new mesh aren’t really appealing to look at. Instead, we’re going to do what every good shader developer does and throw some (simple) math at it to add some lighting to our mesh.
8. Diffuse Lighting
Get Practical Shader Development: Vertex and Fragment Shaders for Game Developers 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.