# Problem with ambient and specular color in vtkLight using vtk 8.2.0 (2)

**URL:** <https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204>\
**Category:** Development\
**Created:** [May 4, 2020, 3:13pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204 "2020-05-04T15:13:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![santichialvo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/santichialvo/32/1248_2.png) [@santichialvo](https://discourse.vtk.org/u/santichialvo)\
**Post date:** [May 4, 2020, 3:13pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/1 "2020-05-04T15:13:52Z")

</div>

Hello,

I’ve some problems related to the methods vtkLight::setSpecularColor and vtkLight::seAmbientColor. I explained the issue in detail in [here](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0/2566/5). I’m not sure if this is a bug, if someone can explain to me what is happening, it would be great.

Regards,  
Santiago.

---

<div class="post-metadata">

**Author:** ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)\
**Post date:** [May 4, 2020, 4:49pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/2 "2020-05-04T16:49:11Z")

</div>

What are you trying to achieve? Do you want to reproduce the same result than VTK 6.3?

Yes, the result changed between OpenGL and OpenGL2 but the whole rendering engine has been reworked.  
Specular color has no physical meaning for lights, the lights have only a radiance color that you can set using `SetColor` (specular and ambient colors are indeed ignored and deprecated now but it is not a bug).  
Specular lobe and diffuse component are computed based on the material specification.  
You need to specify diffuse, specular and shininess (specular power) on the `vtkProperty` class.

Note that starting from VTK 9.0, you can alternatively compute diffuse/specular/shininess automatically based on color/roughness/metallic properties with the new physically based shader.

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [May 5, 2020, 10:07pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/3 "2020-05-05T22:07:12Z")

</div>

The point raised by Santiago is that the red source has (0.5 0 0) as specular color while the blue source has (0 0 1.0) as specular color (both sources are at the same distance from the sphere actor). The OpenGL backend yielded the expected result with a smaller red specular blob as it is half the intensity of the blue source, whereas OpenGL2 beackend rendered specular blobs about the same size.

---

<div class="post-metadata">

**Author:** ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)\
**Post date:** [May 6, 2020, 7:08am UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/4 "2020-05-06T07:08:13Z")

</div>

In his test, the red light is (1,0,0) not (0.5,0,0):

```auto
// Set up the lighting.
  // Light one is on the left and is blue.
  auto light1 = vtkSmartPointer<vtkLight>::New();
  light1->SetFocalPoint(0, 0, 0);
  light1->SetPosition(1, 0, 0);
  light1->SetColor(0, 0, 1);
  light1->SetSpecularColor(0, 0, 1.0);
  ren->AddLight(light1);
  // Light one is on the right and is red.
  auto light2 = vtkSmartPointer<vtkLight>::New();
  light2->SetFocalPoint(0, 0, 0);
  light2->SetPosition(-1, 0, 0);
  light2->SetColor(1, 0, 0);
  light2->SetSpecularColor(0.5, 0, 0);
  ren->AddLight(light2);

```

This is what I achieve when I set the light color to (0.5,0,0):  
 ![2020-05-06-090616_window](https://discourse.vtk.org/uploads/default/original/2X/2/2712e1caec149ce7975482962aad3f2220e9f556.png)

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [May 6, 2020, 7:58pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/5 "2020-05-06T19:58:47Z")

</div>

Please, reread the posts carefully. I said:

> [@Paulo\_Carvalho](#):
>
> red source has (0.5 0 0) as specular color

> [@Paulo\_Carvalho](#):
>
> red source has (0.5 0 0) as ----\>specular color\<-----

I didn’t say to change the red color to (0.5 0 0).

---

<div class="post-metadata">

**Author:** ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)\
**Post date:** [May 7, 2020, 6:54am UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/6 "2020-05-07T06:54:11Z")

</div>

> [@Michael](#):
>
> the lights have only a radiance color that you can set using `SetColor` (----\> **specular and ambient colors are indeed ignored and deprecated now** \<---- but it is not a bug).

You can set the light specular color to green if you like, the specular lobe will still be red.

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [May 7, 2020, 11:39am UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/7 "2020-05-07T11:39:30Z")

</div>

Good programming practice tells that a deprecated function should be documented as such. There is even a Doxygen tag for that:

```cpp
/**
 * One-liner to describe this function.
 *
 * @deprecated since 1.0
 * @see backdrop_replacement_function()
 */

```

---

<div class="post-metadata">

**Author:** ![JPouderoux](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jpouderoux/32/316_2.png) [@JPouderoux](https://discourse.vtk.org/u/JPouderoux)\
**Post date:** [May 8, 2020, 2:51pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/8 "2020-05-08T14:51:27Z")

</div>

Paulo,

VTK is an open source project, please do not hesitate to contribute and create a merge request with this suggestion.

J.

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [May 8, 2020, 9:37pm UTC](https://discourse.vtk.org/t/problem-with-ambient-and-specular-color-in-vtklight-using-vtk-8-2-0-2/3204/9 "2020-05-08T21:37:33Z")

</div>

Yeah right, I was expecting that kind of answer.
