by jabbany · 3y ago · 0 comments
By the way, there's more going on in the shader algorithm than you might expect. Here's an explanation of the worksheet:
u, v are coordinates relative to the center of the image
h is radius from center, squared
Section B generates the ball:
B3-8 generates the reflected color on the ball.
B9-11 applies the diffuse illumination to the ball.
B12 adds the illumination highlight.
Section C creates the ground:
C5 puts a shadow directly under the ball.
C13 is the cast shadow of the ball.
Section D creates the sky with a simple gradient
Section E converts the image from two-color to three-colorAnother interesting thing is to try to reverse-engineer the worksheet: section B is the sphere, section C is the ground, and section D is the sky. But then there's the lighting model, shadow, etc.
Somehow I got RGB(255, 50, 194), which is different from the value posted on the chart. Actually, I'm not sure how originally they got 0, since G comes from R and B, which are both positive, and the expression is multiplication and addition.