# AmbientColor on surface representation

**URL:** https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647
**Category:** Development
**Created:** [May 19, 2022, 7:48am UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647 "2022-05-19T07:48:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 19, 2022, 7:48am UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/1 "2022-05-19T07:48:02Z")

</div>

Dear all,

In my c++ custom application I want to the surface representation of my contour filter to a solid color.  
I have tried to change the property but the color doesn’t change.

Can you help me to understand what is wrong in this code?

```auto
contourFilter = builder->createFilter("filters", "Contour", fitsSource);
auto reprSurface = builder->createDataRepresentation(contourFilter->getOutputPort(0), viewCube);
auto reprProxySurface = reprSurface->getProxy();
vtkSMPropertyHelper(reprProxySurface, "Representation").Set("Surface");
double red[3] = { 1.0, 0.0, 0.0 };
vtkSMPropertyHelper(reprProxySurface, "AmbientColor").Set(red, 3);

```

---

<div class="post-metadata">

### Author: ![timothee.chabat](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timothee.chabat/32/5729_2.png) [@timothee.chabat](https://discourse.paraview.org/u/timothee.chabat)
#### Post date: [May 19, 2022, 2:53pm UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/2 "2022-05-19T14:53:22Z")

</div>

Did you update your server state using `reprProxySurface->UpdateVTKObject()` ?

Also you may want to trigger a render in your view after that.

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 19, 2022, 4:30pm UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/3 "2022-05-19T16:30:38Z")

</div>

Yes I do, but the contour continue to be colored by my scalar instead ad the red solid color

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 19, 2022, 6:06pm UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/4 "2022-05-19T18:06:48Z")

</div>

Ambient coloring involves two controls: **Ambient Color** and **Ambient**. Try setting the **Ambient** factor to 1.0. Also, there’s a **Diffuse** factor too. Of you set Ambient to 1, you may want to set Diffuse to 0 to avoid over saturation.

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 20, 2022, 7:11am UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/5 "2022-05-20T07:11:47Z")

</div>

Setting Ambient to 1 and Diffuse to 0 makes my color brighter but the contour filter stays colored with my scalar and not a solid color. I think I need to somehow set the color mapping to “solid color” like I can do with the paraview GUI

---

<div class="post-metadata">

### Author: ![timothee.chabat](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timothee.chabat/32/5729_2.png) [@timothee.chabat](https://discourse.paraview.org/u/timothee.chabat)
#### Post date: [May 20, 2022, 7:40am UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/6 "2022-05-20T07:40:03Z")

</div>

Oh indeed if you have some data coloring already enable then you’ll need to disable it.  
To do that I usually use the `vtkSMPVRepresentationProxy` class, it goes something like :

```cpp
vtkSMPVRepresentationProxy::SetScalarColoring(
  reprProxySurface, nullptr, 0);

```

Note that this class is also usefull to enable the scalar coloring and play with the displayed data ranges.

---

<div class="post-metadata">

### Author: ![fvitello](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fvitello/32/8783_2.png) [@fvitello](https://discourse.paraview.org/u/fvitello)
#### Post date: [May 20, 2022, 8:08am UTC](https://discourse.paraview.org/t/ambientcolor-on-surface-representation/9647/7 "2022-05-20T08:08:47Z")

</div>

Thanks!
