# Drawing Multiple 2D text at 3D position

**URL:** https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084
**Category:** Support
**Created:** [January 16, 2024, 7:40pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084 "2024-01-16T19:40:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Alucard](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alucard](https://discourse.vtk.org/u/Alucard)
#### Post date: [January 16, 2024, 7:40pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/1 "2024-01-16T19:40:37Z")

</div>

I need to draw Multiple 2D text with a 3D position. It can go up to a couple of thousand of text label. I tried using vtkCaptionActor2D, it is doing what i am looking for, but it is very slow.  
I also made some test, using vtkTextActor, but then again its very slow.  
Is there a way to put all the text in a single actor ? I understand the overhead of having so many actor is big. I tried using vtkPropAssembly but no difference.  
Or is there a way to create some kind of custom actor and put my own openGL code so i can draw the text much faster ?

Note that each each text label has a different position and a different text.

---

<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: [January 16, 2024, 7:56pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/2 "2024-01-16T19:56:25Z")

</div>

Hello @Alucard, have you tried [vtkTextMapper](https://vtk.org/doc/nightly/html/classvtkTextMapper.html)?

---

<div class="post-metadata">

### Author: ![Alucard](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alucard](https://discourse.vtk.org/u/Alucard)
#### Post date: [January 17, 2024, 2:43pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/3 "2024-01-17T14:43:27Z")

</div>

Thanks for the answer. I tried to use vtkTextMapper, but it still require to create one actor and one mapper per text, so in the end i still have a lot of actors and I do not see any performance improvement.

---

<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: [January 17, 2024, 3:58pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/4 "2024-01-17T15:58:03Z")

</div>

Can you share some profiler screenshots so we know where the bottleneck is?

---

<div class="post-metadata">

### Author: ![Alucard](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alucard](https://discourse.vtk.org/u/Alucard)
#### Post date: [January 18, 2024, 1:09pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/5 "2024-01-18T13:09:05Z")

</div>

For the vtkCaptionActor2D im not sure where the bottleneck is since it all happen inside the widget, but when I use vtkTextActor, When something move I change the 2D position of the actor so it stays at the 3D position, and it is the vtkTextActor.SetPosition that create the bottleneck.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [January 26, 2024, 4:10am UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/6 "2024-01-26T04:10:11Z")

</div>

vtkLabelPlacementMapper is intended for displaying many (hundreds or thousands) of labels in 3D. It seems to me that the class is incomplete (probably funding ran out before the work was done), for example the automatic perturbation of overlapping label positions and drawing of spokes is not fully implemented.

---

<div class="post-metadata">

### Author: ![jie\_baoer](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jie_baoer/32/7202_2.png) [@jie\_baoer](https://discourse.vtk.org/u/jie_baoer)
#### Post date: [April 7, 2024, 1:02am UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/7 "2024-04-07T01:02:01Z")

</div>

> [@Alucard](#):
>
> it is doing what i am looking for, but it is very slow.  
> I also made some test, using vtkTextActor, but then again its very slow.

Hi Alucard, I have the same problem when drawing a large number of tags (possibly thousands), the interactor becomes very slow, have you found a solution?

---

<div class="post-metadata">

### Author: ![Alucard](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alucard](https://discourse.vtk.org/u/Alucard)
#### Post date: [April 26, 2024, 3:44pm UTC](https://discourse.vtk.org/t/drawing-multiple-2d-text-at-3d-position/13084/8 "2024-04-26T15:44:37Z")

</div>

For now what I did is I made a function to decide to hide label that overlaps another label at each frame. this way there is much less visible label and rendering is much faster.

The drawback is that its long to add many label, renderer-\>AddActor2D is getting a bit slow if you need to add lots of text actor. Its only needed to do one time but still, in my worst case it takes 2 minutes where in another engine (Irrlicht) I was able to do the same task in 20 second without any rendering problem.  
I have found no way of having multiple text in a single actor, I think that would be my ideal solution.
