A shader program that renders an object with simple diffuse lighting. This shader program builds on our previous shader, https://shaderfrog.com/app/view/3151. To get this shader, we reintroduce the external color variable. We also add a directionToLight variable, which points to the light source. To calculate the diffuse lighting on this object, we calculate the dot product of the normal of the surface and the direction to the light. This gives the cosine of the angle between the surface the light source, effectively giving us the amount of the light the reaches the surface. We call this diffuse lighting. Although this lighting is simple to calculate, it has several problems. First, it does not calculate shadows. Second, it does not calculate ambient lighting or diffuse bleeding. Third, it assumes the light source is infinitely far away (which is not a bad assumption for lighting from the sun, but fails under must other cases). Clearly, this is a biased form of rendering. Created for Computer Graphics 4620, a course offered at the University of Nebraska at Omaha. @bricksphd
This shader has no tags.