The surface normal on this sphere is taken by computing the intersection point, A, and treating this as a euclidean vector with origin, B, the center of the sphere. To normalize it, I first subtracted A with B, yielding C:
C = (Ax-Bx,Ay-By)
From this, it's divided by the magnitude:
N = C/|C|
The illumination is calculated by taking the dot product of N and LIGHT_SOURCE and multiplying it with 255:
if (dot_product<0.0) dot_product = 0.0; illumination = (unsigned char)(dot_product*255.0);
I expected the shade to be something like it's brighter on the middle and becoming more dimmer on the side.
Anyone know what's causing the problem?
This can be compiled if you already have libpng16.