Material Color in Phong Shading Model

0

I'm implementing a lighting model using the Phong formulation as a reference. It was not clear to me how Phong introduces the color of the illuminated material into the equation. The basic equation that I am using for each pixel, for a point of light, is given as follows:

Result.R := Ia.R*ka.R + P.IL.R*((M.kd.R*LN) + (M.ks.R*Power(Max(VR,0),M.Ns)));
Result.G := Ia.G*ka.G + P.IL.G*((M.kd.G*LN) + (M.ks.G*Power(Max(VR,0),M.Ns)));
Result.B := Ia.B*ka.B + P.IL.B*((M.kd.B*LN) + (M.ks.B*Power(Max(VR,0),M.Ns)));

Result.R := Round(Result.R*255/3);
Result.G := Round(Result.G*255/3);
Result.B := Round(Result.B*255/3);

(* Where:
   Result : (R,G,B) color of pixel;
   Ia: intensity of Ambient Light for each component R, G, B;
   ka: material coefficient for reflection of ambient light;
   P: Dot Light;
   IL: intensity of Dot Light for each component R, G, B;
   kd: material coefficient for diffuse reflection of Dot Light;
   ks: material coefficient for specular reflection of Dot Light;
   LN: dot product (L.N);
   VR: dot product (V.R);
   L: Vector from pixel to Dot Light;
   N: Normal vector on the pixel;
   V: Vector from pixel to Observer;
   R: Reflected vector of L relative to N; *)

As the maximum value of each installment is 1 (total 3), I make an adjustment to stay in the range of 0 to 255:

    Result.R := Round(Result.R*255/3);
    Result.G := Round(Result.G*255/3);
    Result.B := Round(Result.B*255/3);

This is not exactly programmed because, when there is more than one point of light, the diffuse and specular components of each light are summed in Result. Component Ia * ka does not change. Instead of dividing up by 3, divide by another number (if they are two lights, divide by 5, if they are three, by 7, and so on).

This type of implementation allows me to control the color of the material by the coefficients ka, kd and ks. The light color is controlled by Ia (ambient light) and P.IL. The template I'm following looks like what's in the link: link

What other ways to introduce the color of the material into the equation? I know there are several versions of Phong, but what are the possibilities for coloring the material and the lights?

    
asked by anonymous 15.03.2016 / 21:54

0 answers