<p>This question is conflating different lighting models, Phong lighting has no concept of dielectrics and the referenced website is clearly just comparing the Phong models to more physically based models. All the websites listed are consistent in their presentation of the Phong model which is fundamentally and intentionally simple as it reflects the capabilities of the hardware it was designed to run on. ( I agree that the flip code site is confusing and the formula's don't even display correctly in my browser)</p>
<p><span class="math-container">$I_p$</span> reads as <em>intensity sub point</em> this is what the entire goal of computing the lighting is. Once intensity is computed for the lighting it is multiplied by the point color and its done. Again, this is for the Phong lighting model. <span class="math-container">$k_a$</span>, <span class="math-container">$k_d$</span> and <span class="math-container">$k_s$</span> are constants used to compute <span class="math-container">$I_p$</span> that is why they are on the <em>right hand side of the equation</em>. Once <span class="math-container">$I_p$</span> is computed <span class="math-container">$k_a$</span>, <span class="math-container">$k_d$</span> and <span class="math-container">$k_s$</span> are no longer needed and do not participate in lighting calculations further.</p>
<p>To talk it through...
The term <span class="math-container">$k_ai_a$</span> represents the ambient contribution of the light. Think of a room painted bright red with a white light in it. The &quot;ambient&quot; light in the room is going to pick up a red color as it bounces off all those red walls. <span class="math-container">$k_a$</span> is most often used to represent that red color while <span class="math-container">$i_a$</span> represents the  intensity of that light. When multiplied they represent the ambient term for the lighting calculation. <span class="math-container">$i_a$</span> is usually just a floating point value and is very small relative to diffuse and specular. Some models will drop the ambient term all together. (but then they are no longer a true Phong lighting model). In real code this term is almost always a pre-multiplied constant and is not actually computed.</p>
<p><span class="math-container">$k_d(\hat{L}_m⋅N)i_{m,d}$</span> here <span class="math-container">$k_d$</span> is a constant and again is almost always used as the color of the light, in this example it would be white. <span class="math-container">$(\hat{L}_m⋅N)$</span> is the cosine of the angle between the light the surface normal, and <span class="math-container">$I_{m,d}$</span> is the intensity of the diffuse light. When multiplied out this term represents the &quot;diffuse&quot; component of the light. In real code the terms <span class="math-container">$k_d$</span> and <span class="math-container">$I_{m,d}$</span> are almost always a pre-multiplied constant and are not actually computed.</p>
<p>Finally, <span class="math-container">$k_s(\hat{R}_m⋅\hat{V})^αi_{m,s}$</span> here again <span class="math-container">$k_s$</span> is a constant, and again almost always a color representing the light and <span class="math-container">$k_s$</span> almost always is equal to <span class="math-container">$k_d$</span>. Next <span class="math-container">$i_{m,s}$</span> is the specular intensity and it is almost always equal to diffuse intensity, and again is pre-multiplied with <span class="math-container">$k_s$</span>, is very frequently the same value used for diffuse and is usually constant for a given light. The value <span class="math-container">$(\hat{R}_m⋅\hat{V})^α$</span> is the cosine of the angle between view vector and the reflection vector raised to the specular power <span class="math-container">$\alpha$</span>. Once computed this term represents specular intensity. So in this case the specular <span class="math-container">$k_s$</span> is white and the intensity is equal to <span class="math-container">$i_d$</span>. (so we end up with the same constant used to compute the diffuse term)</p>
<p>Now add them up... A little bit of red light from the ambient plus the diffuse light which is a bright white plus very bright white highlights from the specular. This is <span class="math-container">$I_p$</span>, call it &quot;light_intensity&quot; now figure out the color of the point, and compute the final color...</p>
<pre><code>// lets make the color a constant blue-green...
vec4 point_color = vec4(0.0,0.2,0.8, 1.0);
final_color = light_intensity * point_color;
</code></pre>

CC BY-SA 4.0
2022-08-03T13:13:59.167Z
So you're saying that $k_d$ and $k_s$ are properties of the light rather than of the material being illuminated?  That conflicts with what I've seen in most other sources.
jwodder
CC BY-SA 4.0
2022-08-03T16:14:46.473Z
It doesn't matter where these constants come from. They can be constants in the shader, they can be stored in a material, they can come from a texture, it doesn't matter.
pmw1234
CC BY-SA 4.0
2022-08-03T19:16:11.833Z
But are $k_d$ and $k_s$ associated with the light source — and thus have different values for different lights — or are they associated with the materials being illuminated — and thus have different values when considering a different material under the same light?
jwodder
CC BY-SA 4.0
2022-08-03T21:52:16.583Z
Unfortunately the answer to that is all of the above as it depends on the situation. This is one of the several reasons that Phong lighting models tend to use fixed lighting.  The desire would be to fix them based on the material, and this can work in simple scenes, but in more complex scene's the colors can interact with lights in unexpected ways. This leads to artists "tweaking" values to get the scene to "look its best". Move a light, change a value, and ugly artifacts emerge. This can lead to scene specific materials where the only value that is different is the constant color.
pmw1234
CC BY-SA 4.0
2022-08-04T07:15:21.100Z
$k_d, k_s$ are not related to the light, those are material/brdf parameters.
lightxbulb
CC BY-SA 4.0
2022-08-04T11:01:38.103Z
that is literally what I just said
pmw1234
CC BY-SA 4.0
2022-08-03T11:07:41.513Z
2022-08-03T11:13:09.243Z
2022-08-03T11:13:09.243Z
pmw1234
<p>According to chapter 6 of <a href="http://raytracerchallenge.com" rel="nofollow noreferrer"><em>The Ray Tracer Challenge</em> by Jamis Buck</a>, in order to get the final color, the color of the material is multiplied by the ambient term and the diffuse term but not by the specular term.  <span class="math-container">$k_a$</span>, <span class="math-container">$k_d$</span>, and <span class="math-container">$k_s$</span>, meanwhile, are simply material properties in the range <span class="math-container">$[0,1]$</span>.</p>

CC BY-SA 4.0
2022-08-03T09:28:44.350Z
The original question should be edited if adding to the questions, this doesn't answer the question at all.
pmw1234
CC BY-SA 4.0
2022-08-03T13:12:41.157Z
@pmw1234: This was intended to be an answer to the question, as the referenced work was the first source I found that comprehensively addressed the question of combining Phong illumination with a colored material.  You may think the answer is wrong, but that doesn't make it not an answer.
jwodder
CC BY-SA 4.0
2022-08-03T16:23:59.997Z
These models are *all* approximations. Feel free to take your favorite approximation and run with it. The internet has thousands of versions (for better or worse) of "Phong" lighting. The "correct" solution is the one that fits best with the situation.
pmw1234
CC BY-SA 4.0
2022-07-30T18:50:39.450Z
2022-07-30T18:50:39.450Z
jwodder
<p>The formula for Phong illumination <a href="https://en.wikipedia.org/wiki/Phong_reflection_model#Description" rel="nofollow noreferrer">as given on Wikipedia</a> (see there for the variable definitions) is:</p>
<p><span class="math-container">$$I_\text{p} = k_\text{a} i_\text{a} + \sum_{m\;\in\;\text{lights}} (k_\text{d} (\hat{L}_m \cdot \hat{N}) i_{m,\text{d}} + k_\text{s} (\hat{R}_m \cdot \hat{V})^{\alpha}i_{m,\text{s}})$$</span></p>
<p>This gives the &quot;illumination&quot; of a point on a surface.  However, once I've calculated that, how do I take the color of the surface into account to find the final value of, say, a raytraced pixel?  Do I just multiply the illumination by the surface color's RGB components?  Are the RGB components expected to have already been taken into account in the <span class="math-container">$k_a, k_d, k_s$</span> terms?  None of the raytracing tutorials I've found online come out and give a straight answer to this question, aside from <a href="https://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_2_Phong_Mirrors_and_Shadows.shtml" rel="nofollow noreferrer">this</a>, which multiplies the diffuse term but not the specular term by the surface color (and omits the ambient term entirely), something which <a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/phong-shader-BRDF" rel="nofollow noreferrer">this page</a> implies should only be done for dielectrics.</p>

CC BY-SA 4.0
2022-07-28T19:03:24.023Z
$k_d$ is the diffuse albedo, which the surface "color" represented in RGB.
Hubble
CC BY-SA 4.0
2022-07-28T19:26:50.853Z
@Hubble: Are you saying that $k_d$ equals the color or that it equals the color multiplied by a material-specific constant?  Either way, that sounds like an answer, moreso if you link to some comprehensive reference on this.
jwodder
CC BY-SA 4.0
2022-07-29T07:14:57.247Z
The expression you wrote is "valid" only if you consider directional lights, you ignore shadows, and also the ambient term is a hack. If you're doing path tracing then you phong brdf is made up of two parts: the diffuse part is just a standard Lambertian, while the specular part is  $C(R\cdot V)^{\alpha}/(N\cdot L)$, where $C$ is a suitable constant. Look up the Global Illumination Compendium from Dutre.
lightxbulb
CC BY-SA 4.0
2022-07-30T21:50:03.143Z
The answer to this depends on what your definition of a color is. If you think rgb is the epitome of color then sure multiply light color by surface color. But if you think color is a spectrum then you need to multiply by spectrum slices and then repuild it as rgb
joojaa
<raytracing><lighting><color><shading>
Applying Phong illumination to a colored surface
jwodder
# Applying Phong illumination to a colored surface

(Asked by: username_0 on 2022-07-28)

The formula for Phong illumination [as given on Wikipedia](https://en.wikipedia.org/wiki/Phong_reflection_model#Description) (see there for the variable definitions) is:

$$I\_\text{p} = k\_\text{a} i\_\text{a} + \sum\_{m\;\in\;\text{lights}} (k\_\text{d} (\hat{L}\_m \cdot \hat{N}) i\_{m,\text{d}} + k\_\text{s} (\hat{R}\_m \cdot \hat{V})^{\alpha}i\_{m,\text{s}})$$

This gives the "illumination" of a point on a surface. However, once I've calculated that, how do I take the color of the surface into account to find the final value of, say, a raytraced pixel? Do I just multiply the illumination by the surface color's RGB components? Are the RGB components expected to have already been taken into account in the $k\_a, k\_d, k\_s$ terms? None of the raytracing tutorials I've found online come out and give a straight answer to this question, aside from [this](https://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_2_Phong_Mirrors_and_Shadows.shtml), which multiplies the diffuse term but not the specular term by the surface color (and omits the ambient term entirely), something which [this page](https://www.scratchapixel.com/lessons/3d-basic-rendering/phong-shader-BRDF) implies should only be done for dielectrics.

**Tags:** raytracing, lighting, color, shading

> **Comments:**
> **username_1**: $k_d$ is the diffuse albedo, which the surface "color" represented in RGB.  
> **username_0**: @username_1: Are you saying that $k_d$ equals the color or that it equals the color multiplied by a material-specific constant?  Either way, that sounds like an answer, moreso if you link to some comprehensive reference on this.  
> **username_2**: The expression you wrote is "valid" only if you consider directional lights, you ignore shadows, and also the ambient term is a hack. If you're doing path tracing then you phong brdf is made up of two parts: the diffuse part is just a standard Lambertian, while the specular part is  $C(R\cdot V)^{\alpha}/(N\cdot L)$, where $C$ is a suitable constant. Look up the Global Illumination Compendium from Dutre.  
> **username_3**: The answer to this depends on what your definition of a color is. If you think rgb is the epitome of color then sure multiply light color by surface color. But if you think color is a spectrum then you need to multiply by spectrum slices and then repuild it as rgb  

---

## 2 answers

### Answer by username_4 on 2022-08-03. Score: 1

This question is conflating different lighting models, Phong lighting has no concept of dielectrics and the referenced website is clearly just comparing the Phong models to more physically based models. All the websites listed are consistent in their presentation of the Phong model which is fundamentally and intentionally simple as it reflects the capabilities of the hardware it was designed to run on. ( I agree that the flip code site is confusing and the formula's don't even display correctly in my browser)

$I\_p$ reads as *intensity sub point* this is what the entire goal of computing the lighting is. Once intensity is computed for the lighting it is multiplied by the point color and its done. Again, this is for the Phong lighting model. $k\_a$, $k\_d$ and $k\_s$ are constants used to compute $I\_p$ that is why they are on the *right hand side of the equation*. Once $I\_p$ is computed $k\_a$, $k\_d$ and $k\_s$ are no longer needed and do not participate in lighting calculations further.

To talk it through...
The term $k\_ai\_a$ represents the ambient contribution of the light. Think of a room painted bright red with a white light in it. The "ambient" light in the room is going to pick up a red color as it bounces off all those red walls. $k\_a$ is most often used to represent that red color while $i\_a$ represents the intensity of that light. When multiplied they represent the ambient term for the lighting calculation. $i\_a$ is usually just a floating point value and is very small relative to diffuse and specular. Some models will drop the ambient term all together. (but then they are no longer a true Phong lighting model). In real code this term is almost always a pre-multiplied constant and is not actually computed.

$k\_d(\hat{L}\_m⋅N)i\_{m,d}$ here $k\_d$ is a constant and again is almost always used as the color of the light, in this example it would be white. $(\hat{L}\_m⋅N)$ is the cosine of the angle between the light the surface normal, and $I\_{m,d}$ is the intensity of the diffuse light. When multiplied out this term represents the "diffuse" component of the light. In real code the terms $k\_d$ and $I\_{m,d}$ are almost always a pre-multiplied constant and are not actually computed.

Finally, $k\_s(\hat{R}\_m⋅\hat{V})^αi\_{m,s}$ here again $k\_s$ is a constant, and again almost always a color representing the light and $k\_s$ almost always is equal to $k\_d$. Next $i\_{m,s}$ is the specular intensity and it is almost always equal to diffuse intensity, and again is pre-multiplied with $k\_s$, is very frequently the same value used for diffuse and is usually constant for a given light. The value $(\hat{R}\_m⋅\hat{V})^α$ is the cosine of the angle between view vector and the reflection vector raised to the specular power $\alpha$. Once computed this term represents specular intensity. So in this case the specular $k\_s$ is white and the intensity is equal to $i\_d$. (so we end up with the same constant used to compute the diffuse term)

Now add them up... A little bit of red light from the ambient plus the diffuse light which is a bright white plus very bright white highlights from the specular. This is $I\_p$, call it "light\_intensity" now figure out the color of the point, and compute the final color...

```
// lets make the color a constant blue-green...
vec4 point_color = vec4(0.0,0.2,0.8, 1.0);
final_color = light_intensity * point_color;

```

> **Comments:**
> **username_0**: So you're saying that $k_d$ and $k_s$ are properties of the light rather than of the material being illuminated?  That conflicts with what I've seen in most other sources.  
> **username_4**: It doesn't matter where these constants come from. They can be constants in the shader, they can be stored in a material, they can come from a texture, it doesn't matter.  
> **username_0**: But are $k_d$ and $k_s$ associated with the light source — and thus have different values for different lights — or are they associated with the materials being illuminated — and thus have different values when considering a different material under the same light?  
> **username_4**: Unfortunately the answer to that is all of the above as it depends on the situation. This is one of the several reasons that Phong lighting models tend to use fixed lighting.  The desire would be to fix them based on the material, and this can work in simple scenes, but in more complex scene's the colors can interact with lights in unexpected ways. This leads to artists "tweaking" values to get the scene to "look its best". Move a light, change a value, and ugly artifacts emerge. This can lead to scene specific materials where the only value that is different is the constant color.  
> **username_2**: $k_d, k_s$ are not related to the light, those are material/brdf parameters.  
> **username_4**: that is literally what I just said  

---

### Answer by username_0 on 2022-07-30. Score: 0

According to chapter 6 of [*The Ray Tracer Challenge* by Jamis Buck](http://raytracerchallenge.com), in order to get the final color, the color of the material is multiplied by the ambient term and the diffuse term but not by the specular term. $k\_a$, $k\_d$, and $k\_s$, meanwhile, are simply material properties in the range $[0,1]$.

> **Comments:**
> **username_4**: The original question should be edited if adding to the questions, this doesn't answer the question at all.  
> **username_0**: @username_4: This was intended to be an answer to the question, as the referenced work was the first source I found that comprehensively addressed the question of combining Phong illumination with a colored material.  You may think the answer is wrong, but that doesn't make it not an answer.  
> **username_4**: These models are *all* approximations. Feel free to take your favorite approximation and run with it. The internet has thousands of versions (for better or worse) of "Phong" lighting. The "correct" solution is the one that fits best with the situation.  

---

