<p>The relevant equation on the Wikipedia page follows:</p>

<p>$$
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}})
$$</p>

<p>In this equation, all the $k$ and $i$ terms are not numbers but colours (RGB intensities). This includes $k_a$ and $i_a$: the ambient colour of the object, and the ambient illumination colour, respectively. The ambient term isn't a constant: it's a product of an intensity and albedo, just like the specular and diffuse terms. The only difference is that the lighting and view directions aren't a factor in this term.</p>

<p>It's very unusual to have $k_a$ different from the diffuse colour, so you can think of it as multiplying by "the colour of the object". That said, it's quite common for $i_a$ to be a distinct colour: for example, if you're using a yellowish directional light for direct sunlight, you might want the ambient light to be blueish to stand in for skylight.</p>

CC BY-SA 3.0
2017-07-05T16:23:00.687Z
Thank you! Both your answer and Michal's answer explained it to me very well. I'll have to remember this next time a code a shader.
Daniel Kareh
CC BY-SA 3.0
2017-07-05T15:26:14.490Z
2017-07-05T15:26:14.490Z
Dan Hulme
<p>I think we should have both and also have a factor based on material</p>

<p>Some material has high diffusive so it will reflect only light of its own color. But some material can also reflect some light as it is. For the phong shader I think we use additive ambient because phong object tends to reflect all light and so ambient light could be lit it with that light's color, but other lights was used to make diffuse color</p>

<p>On the contrary to lambert, if what I know is right, are material with high diffusion, and so the ambient light was added to the lit and multiply by material's color</p>

<p>I guess modern shader should have a parameter to set this factor and write equation like this</p>

<pre><code>float factor; // 0.0 - 1.0 maybe reflectiveness?
float3 light = (factor * ambient.rgb); // ambient light
light += _MainLightColor.rgb * dot(normal,_MainLightDirection); // lambert
// maybe also specular
float3 color = ((1 - factor) * ambient.rgb) + (matColor * light);
</code></pre>

<p>Actually I take this concept from PBR material, there was a concept of energy conservation. All the light may lit the object by diffusion or reflection but to conserve energy, more diffuse color means lower reflection. And so ambient light just add more light energy, then get treat as the same as other light</p>

CC BY-SA 4.0
2020-02-17T05:11:32.777Z
2020-02-17T05:11:32.777Z
Thaina
<p>Correct is the OpenGL way. If you had a white light ( let's say vec3(255,255,255) )
and just simply added it to a blue object ( vec3(0,0,255) ), the object would seem to be white, which is wrong. But if you were to multiply these colors, the object would be fully illuminated and correctly blue (which is the desired product).</p>

<p>The thing with ambient light is that it is only influenced by the ambient light intensity and by the color of the object, which means it is not influenced by the lights position, direction or anything of the sort. That is why you can think of it as "simply adding it as a constant".</p>

<p>We use ambient light mostly to simulate reflected light in the scene, which is very hard to simulate otherwise (without raytracing). It's a fairly good and cheap alternative.</p>

CC BY-SA 3.0
2017-07-05T16:24:00.770Z
Thank you! Your answer as well as Dan's answer covered my question very well. I'll make sure to use this new piece of knowledge.
Daniel Kareh
CC BY-SA 3.0
2017-07-05T15:17:50.497Z
2017-07-05T15:17:50.497Z
Michal Kučera
<p>On the Wikipedia page for the <a href="https://en.wikipedia.org/wiki/Phong_reflection_model" rel="noreferrer" title="Phong reflection model">Phong model</a>, it says that the ambient term is a constant, and just gets added on to the other terms. But on other pages like <a href="https://learnopengl.com/#!Lighting/Basic-Lighting" rel="noreferrer" title="Learn OpenGL">LearnOpenGL</a> it says you should take the ambient term and multiply it by the color of the object. Which one is correct?</p>

CC BY-SA 3.0
2017-07-06T00:46:04.340Z
Note that later in the article, wikipedia says "When the color is represented as RGB values, as often is the case in computer graphics, this equation is typically modeled separately for R, G and B intensities, allowing different reflections constants k a , {\displaystyle k_{\text{a}},} k_{\text{a}}, k d {\displaystyle k_{\text{d}}} k_{\text{d}} and k s {\displaystyle k_{\text{s}}} k_{\text{s}} for the different color channels."
Cort Ammon
<rendering><lighting>
Ambient Lighting
Daniel Kareh
# Ambient Lighting

(Asked by: username_0 on 2017-07-05)

On the Wikipedia page for the [Phong model](https://en.wikipedia.org/wiki/Phong_reflection_model "Phong reflection model"), it says that the ambient term is a constant, and just gets added on to the other terms. But on other pages like [LearnOpenGL](https://learnopengl.com/#!Lighting/Basic-Lighting "Learn OpenGL") it says you should take the ambient term and multiply it by the color of the object. Which one is correct?

**Tags:** rendering, lighting

> **Comments:**
> **username_1**: Note that later in the article, wikipedia says "When the color is represented as RGB values, as often is the case in computer graphics, this equation is typically modeled separately for R, G and B intensities, allowing different reflections constants k a , {\displaystyle k_{\text{a}},} k_{\text{a}}, k d {\displaystyle k_{\text{d}}} k_{\text{d}} and k s {\displaystyle k_{\text{s}}} k_{\text{s}} for the different color channels."  

---

## 3 answers

### Answer by username_4 on 2017-07-05. Score: 7 | Accepted answer

Correct is the OpenGL way. If you had a white light ( let's say vec3(255,255,255) )
and just simply added it to a blue object ( vec3(0,0,255) ), the object would seem to be white, which is wrong. But if you were to multiply these colors, the object would be fully illuminated and correctly blue (which is the desired product).

The thing with ambient light is that it is only influenced by the ambient light intensity and by the color of the object, which means it is not influenced by the lights position, direction or anything of the sort. That is why you can think of it as "simply adding it as a constant".

We use ambient light mostly to simulate reflected light in the scene, which is very hard to simulate otherwise (without raytracing). It's a fairly good and cheap alternative.

> **Comments:**
> **username_0**: Thank you! Your answer as well as Dan's answer covered my question very well. I'll make sure to use this new piece of knowledge.  

---

### Answer by username_2 on 2017-07-05. Score: 5

The relevant equation on the Wikipedia page follows:

$$
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}})
$$

In this equation, all the $k$ and $i$ terms are not numbers but colours (RGB intensities). This includes $k\_a$ and $i\_a$: the ambient colour of the object, and the ambient illumination colour, respectively. The ambient term isn't a constant: it's a product of an intensity and albedo, just like the specular and diffuse terms. The only difference is that the lighting and view directions aren't a factor in this term.

It's very unusual to have $k\_a$ different from the diffuse colour, so you can think of it as multiplying by "the colour of the object". That said, it's quite common for $i\_a$ to be a distinct colour: for example, if you're using a yellowish directional light for direct sunlight, you might want the ambient light to be blueish to stand in for skylight.

> **Comments:**
> **username_0**: Thank you! Both your answer and username_4's answer explained it to me very well. I'll have to remember this next time a code a shader.  

---

### Answer by username_3 on 2020-02-17. Score: 0

I think we should have both and also have a factor based on material

Some material has high diffusive so it will reflect only light of its own color. But some material can also reflect some light as it is. For the phong shader I think we use additive ambient because phong object tends to reflect all light and so ambient light could be lit it with that light's color, but other lights was used to make diffuse color

On the contrary to lambert, if what I know is right, are material with high diffusion, and so the ambient light was added to the lit and multiply by material's color

I guess modern shader should have a parameter to set this factor and write equation like this

```
float factor; // 0.0 - 1.0 maybe reflectiveness?
float3 light = (factor * ambient.rgb); // ambient light
light += _MainLightColor.rgb * dot(normal,_MainLightDirection); // lambert
// maybe also specular
float3 color = ((1 - factor) * ambient.rgb) + (matColor * light);

```

Actually I take this concept from PBR material, there was a concept of energy conservation. All the light may lit the object by diffusion or reflection but to conserve energy, more diffuse color means lower reflection. And so ambient light just add more light energy, then get treat as the same as other light


---

