CSE 167 Lecture Notes - Lecture 7: Phong Shading, Shader, Opengl
Document Summary
The way shading is done is also important. Flat:entire face has single color (normal) from 1 vertex. Gouraud or smooth: colors at each vertex, interpolate. Can mix primaries to get other colors. Point: light source is at a single point in the world. Directional: assumed to be infinitely far away, so directions is the same for every vector. At vertices, then shade at each pixel in fragment shader. Scan line ys with intersection points ia, ib. // slope intersection form x(y) = y/m - c/m x(y+1) = y/m + 1/m - c/m = x(y) + 1/m. Ia = [i1(w1) + i2(w2)] / (y1 - y2) Ib = [i1(ys - y3) + i3(y1 - ys)] / (y1 - y3) W2 = (y1 - ys)/ (y1 - y2) w1 = (ys - y2) / (y1 - y2) if ys = y2, w1 = 1. Ip = iawa + ibwb wa = (xb - xp) / (xb - xa)