# Different colors for different parts of the glyph when using the vtkGlyph3DMapper

**URL:** https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077
**Category:** Support
**Created:** [December 26, 2024, 4:25pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077 "2024-12-26T16:25:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hui](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hui/32/9656_2.png) [@hui](https://discourse.vtk.org/u/hui)
#### Post date: [December 26, 2024, 4:25pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/1 "2024-12-26T16:25:07Z")

</div>

Hello,

I want to display each point of my point cloud as a circle with a disk as its edge. And I want the circle and the disk to have different colors. I tried vtkGlyph3DMapper with a vtkRegularPolygonSource and a vtkDiskSource combined by a vtkAppendPolyData. The glyph displayed but it always has a single color. I tried setting scalars to both sources, to the combined polydata but none of these works. Is there a way to make this work? If not, are there other alternatives?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [December 26, 2024, 4:44pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/2 "2024-12-26T16:44:23Z")

</div>

No, this is not currently possible because the glyph mapper can only map scalars from the input dataset’s points.

Instead, you can take a different approach. Do not append. Use the inner polygon as source for one glyph mapper and the disk for another glyph mapper. Connect both mappers to the same input point cloud. Assign the two mappers to two separate actors. Finally, set the color on each actor’s property to whatever you want.

---

<div class="post-metadata">

### Author: ![hui](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hui/32/9656_2.png) [@hui](https://discourse.vtk.org/u/hui)
#### Post date: [December 26, 2024, 11:08pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/3 "2024-12-26T23:08:29Z")

</div>

Thanks, this saves me a lot of time. Using separate mappers sounds like a good idea, although it may make picking more complicated but I guess I will have to have a try. Another question is can I assign different colors for the front and back side of the glyph? I need a way to differentiate the front and back but for now they looks the same even when I set the normals.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [December 27, 2024, 2:22pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/4 "2024-12-27T14:22:10Z")

</div>

> [@hui](#):
>
> although it may make picking more complicate

If your concern is dealing with two different prop IDs in the selection callback, try adding both of those actors as parts of a `vtkAssembly` and add the assembly into the renderer. Then, in your picker callback, the `vtkAbstractPropPicker::GetAssembly()` will return the assembly instead of an individual part.

> [@hui](#):
>
> Another question is can I assign different colors for the front and back side of the glyph? I need a way to differentiate the front and back but for now they looks the same even when I set the normals.

Yes, it is very easy. You can set the backface colors on the actor’s backface property. Use `actor->GetBackfaceProperty()`. It is also an instance of `vtkProperty`.

---

<div class="post-metadata">

### Author: ![hui](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hui/32/9656_2.png) [@hui](https://discourse.vtk.org/u/hui)
#### Post date: [December 27, 2024, 3:48pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/5 "2024-12-27T15:48:46Z")

</div>

Thank you Jaswant! using an assembly for selection sounds promising.

Regarding the backface property, I tried creating a backface property with a color for the actor. But after adding that, the actor becomes invisible when looking from the back. I tried set BackfaceCullingOff but it does not work. Does the backface property work with vtkGlyph3DMapper?

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [December 27, 2024, 6:21pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/6 "2024-12-27T18:21:34Z")

</div>

Yes, that’s definitely a bug. I’ve a fix here - [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/11789](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11789)

---

<div class="post-metadata">

### Author: ![hui](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hui/32/9656_2.png) [@hui](https://discourse.vtk.org/u/hui)
#### Post date: [December 28, 2024, 3:12pm UTC](https://discourse.vtk.org/t/different-colors-for-different-parts-of-the-glyph-when-using-the-vtkglyph3dmapper/15077/7 "2024-12-28T15:12:23Z")

</div>

Works like a charm, thanks Jaswant!
