title: Color of Material in Phong Shading Illumination Model
body: <p>I'm implementing an illumination model using as reference Phong formulation.
  It's not quite clear for me yet how to appropriately make possible to render material in different colors. I'm not using textures.
  The basic equations that I'm using for each pixel, given a light point, is shown below:</p>
  
  <pre><code>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; *)
  </code></pre>
  
  <p>The maximum value for each equation is 3, because each parcel (Ia.R*ka.R, for example) is at most 1.
  I adapt the result so each component (Result.R, Result.G and Result.B) stay in the range from 0 to 255.</p>
  
  <p>It's not exactly programmed this way, because when there's more than one Dot Light, I calculate the sum of the Diffuse and Specular components of all lights in Result. The Ia*ka components don't change. Instead of dividing above by 3, it's then divided by another number (if there are 2 Dot Lights, it's divided by 5. If there are 3, by 7, and so on).</p>
  
  <p>This kind of implementation allows me to control the material color through the ka, kd and ks coefficients. The light color overall is controled by Ia and P.IL. The model which I've been following is similar to this <a href="https://en.wikipedia.org/wiki/Phong_reflection_model" rel="nofollow">one</a> I found on Wikipedia.</p>
  
  <p>I would like to know then if I commited some kind of mystake, if I misinterpreted Phong's formulation. I know there are many versions of Phong's Illumination Model, but I would like to learn which ones give the possibility of changing the material and lights colors.</p>
  
  <p>Thanks in advance, I appreciate all the attention and help :)</p>