Consider a monochrome ball. The colours of the pixels is a function of the point height, the light intensity, the light angle, and the surface material (reflection).

enter image description here

What is the simplest formula defining the resulting gradient?

Note that my question is not about raytracing, as we assume a simple object with no inner shadow/reflection. I am just curious what is the simplest relation between the pixel colour and the four parameters (of if there are more).

For every point, we have the coordinate (x,y,z) and the RGB colour of the material (left image). How can we calculate the appearance colour (the right image) in a very basic form?

  • 1
    $\begingroup$ to calculate the light intensity like the right part of your image, you would need the normal vector of you surface. In case of a simple sphere, your normal vector is the normalized position vector. What you are looking for is called Phong shading. Usually it is the sum of 3 different calculations. 1:Ambient light. the whole surface adds a specified color value, 2:Diffuse light. Usually it is the cosine of the angle between light direction and normal vector. 3:Specular light.See Link: mathematik.uni-marburg.de/~thormae/lectures/graphics1/code/… $\endgroup$
    – Thomas
    Feb 21, 2022 at 11:05
  • $\begingroup$ @Thomas wow, that's brilliant. I never thought of the normal vector at each point. The ambient light is the starting colour (given in the 2D image). Since the diffuse light is calculated by the cosine of the angle between the light direction and the normal vector, we can even calculate the shade on the other side of the sphere without raytracing. $\endgroup$
    – Googlebot
    Feb 21, 2022 at 12:06
  • $\begingroup$ The ambient light is the starting color usually with less brightness! The ambient light usually is fake. It is added to the model, so that dark spots (shadow regions) are not totally black. $\endgroup$
    – Thomas
    Feb 21, 2022 at 14:45
  • 1
    $\begingroup$ We call this formula "N dot L". That's pretty simple. The dot product of the surface normal vector (N) and the light vector (L). If both are normalized, results in the cosine of the angle between the vectors. $\endgroup$
    – Wyck
    Feb 22, 2022 at 14:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.