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.
© Kyle Halladay 2019Kyle HalladayPractical Shader Developmenthttps://doi.org/10.1007/978-1-4842-4457-9_8
8. Diffuse Lighting
Our meshes so far have stored position, color, and texture coordinate information for each vertex in the mesh. Lighting calculations rely on a new vertex attribute called a