• Content Count

  • Joined

  • Last visited

Everything posted by drbits

  1. You have to think in 3 dimensions, know something about the light source, and know something about the surface. The discussion below gives a good approximation of the lighting for any curved surface in more than 2 dimensions. If you look at the mathematics of reflection from a curved surface you find (for one light source) intensity[x,y] = Light intensity * reflectance of surface[x,y,z] * cos(angle of incidence[x,y,z]) * cos(angle of view[x,y,z]) The first part is, the intensity of the light times the fraction of light reflected at that spot (a cue ball reflects more than a ball of mat black wall). We can ignore this for the purpose of painting. The angle of incidence is the angle between the light source and the point on the surface. It turns out that the fraction of light reflected is the cosine of that angle. The same goes for the angle between the surface and the viewer's eye. As an approximation, one can use the line between the point on the sphere and the light source and the angle to that line of the sphere surface at that point. Call that angle C. The intensity reduction due to the angle is then cosĀ© squared. As you draw the sphere, you calculate the angle of the centre of the sphere and the part of the sphere represented by the pixel. You then have the information to colour the pixel. You can modify this by the fuzziness of the surface, the reflectance in each of the primary colours, and any other light sources. The orbs you see in ads and other pictures are usually done with a 3-D program that uses a technique called "Ray Tracing" to calculate the colour and intensity of each pixel. Martin Katz, Ph.D. P.S. I used to teach computer graphics programming as a college class.