# SetColor() in scripting lost all light reflection effect

**URL:** <https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398>\
**Category:** Support\
**Tags:** 3d-model, color\
**Created:** [June 17, 2025, 7:32pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398 "2025-06-17T19:32:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chz31](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chz31/32/77363_2.png) [@chz31](https://discourse.slicer.org/u/chz31)\
**Post date:** [June 17, 2025, 7:32pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/1 "2025-06-17T19:32:30Z")

</div>

Whenever I set up color using `modelNode.GetDisplayNode().SetColor()` in Slicer Pytho console or a python script, the model appeared to lose all the light reflection and material effects.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/c/7c1368b761e25c7b9140bb789fcbfb8b144e2ccd.png)

If I just click the color table, and “OK” to select the same select, the color then became normal.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/2/b2c60f95edc3ca35a0657e6fb6aa043bffbb77c0.png)

Did I miss anything in setting the color? Thanks!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 17, 2025, 8:53pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/2 "2025-06-17T20:53:54Z")

</div>

You should use the more specific rendering-related fields like diffuse color, specular color etc.

> **[Slicer: vtkMRMLDisplayNode Class Reference](https://apidocs.slicer.org/main/classvtkMRMLDisplayNode.html)**

---

<div class="post-metadata">

**Author:** ![chz31](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chz31/32/77363_2.png) [@chz31](https://discourse.slicer.org/u/chz31)\
**Post date:** [June 18, 2025, 2:47pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/4 "2025-06-18T14:47:10Z")

</div>

I went through all the settings, including `SetShading(), SetDiffuse, SetSpecular, SetAmbient, and SetLighting`, but none of it worked.

Interestingly, when I used `SetColor` directly in a function in the logic() class, the shading and lighting effects displayed normally.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 18, 2025, 3:40pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/5 "2025-06-18T15:40:17Z")

</div>

`SetColor` is supposed to only change the color, and not the lighting properties. I just tried and it works as expected, so something is different on your side. What Slicer version do you use? What extensions are installed? If you use custom code, what does it do? Do you get any errors/warnings in the log? And whatever information you consider useful…

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 18, 2025, 7:32pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/6 "2025-06-18T19:32:25Z")

</div>

It looks like you have called `SetColor(0, 0, 255)` instead of the correct `SetColor(0, 0, 1)`.

VTK (and therefore Slicer) specifies color and opacity components uses floating point numbers between 0 and 1 to . It is sometimes useful to be able to set color intensity slightly above 100%, but 25500% is way too high, threfore all that you see is the flat ambient color. When you interact with the GUI, it normalizes the value ranges between 0-100%, that’s why after that everything looks normal again.

---

<div class="post-metadata">

**Author:** ![chz31](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chz31/32/77363_2.png) [@chz31](https://discourse.slicer.org/u/chz31)\
**Post date:** [June 18, 2025, 9:20pm UTC](https://discourse.slicer.org/t/setcolor-in-scripting-lost-all-light-reflection-effect/43398/7 "2025-06-18T21:20:52Z")

</div>

@cpinter @lassoan

Yes, I did do SetColor(0, 0, 255). Sorry I did not describe my issue clearly. I did not realize that was the problem. SetColor() with value between 0 to 1 solved my problem. Thanks!
