# Texture Mapping a Tube Uniformly

**URL:** https://discourse.vtk.org/t/texture-mapping-a-tube-uniformly/2854
**Category:** Support
**Created:** [March 19, 2020, 2:27pm UTC](https://discourse.vtk.org/t/texture-mapping-a-tube-uniformly/2854 "2020-03-19T14:27:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TravStu22](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@TravStu22](https://discourse.vtk.org/u/TravStu22)
#### Post date: [March 19, 2020, 2:27pm UTC](https://discourse.vtk.org/t/texture-mapping-a-tube-uniformly/2854/1 "2020-03-19T14:27:51Z")

</div>

Hi, when trying to texture map a tube, I see the first strip gets the full texture and the rest of the strips get the full texture again stretched amongst them. I would like the texture to be applied evenly along all the strips.

Take this texture for example,  
 ![texture](https://discourse.vtk.org/uploads/default/original/2X/3/342ff9ccd7ae300fc77d028c2102fe18b677bff4.png)

I get results like this for a 12 sided tube:  
 ![tube12](https://discourse.vtk.org/uploads/default/original/2X/7/750cca1bf895c47e49e2d87b10d0630f4e2e8247.png)

And with a 3 sided tube:  
 ![tube3](https://discourse.vtk.org/uploads/default/original/2X/a/ab9413cd7d9406d68309f05cfe84ce3e5ada52f4.png)

Here is sample code to reproduce this with python3.7-vtk8.1.2:

```
import vtk

renderer = vtk.vtkRenderer()

tube_points = vtk.vtkPoints()
tube_points.InsertNextPoint(0, -10, 0)
tube_points.InsertNextPoint(0, 10, 0)

tube_lines = vtk.vtkCellArray()
tube_lines.InsertNextCell(2)
tube_lines.InsertCellPoint(0)
tube_lines.InsertCellPoint(1)

tube_poly_data = vtk.vtkPolyData()
tube_poly_data.SetPoints(tube_points)
tube_poly_data.SetLines(tube_lines)

tube = vtk.vtkTubeFilter()
tube.SetInputData(tube_poly_data)
tube.SetNumberOfSides(12)
tube.SetRadius(2)
tube.SetGenerateTCoordsToUseLength()

reader = vtk.vtkPNGReader()
reader.SetFileName('texture.png')

texture = vtk.vtkTexture()
texture.SetInputConnection(reader.GetOutputPort())

tube_mapper = vtk.vtkPolyDataMapper()
tube_mapper.SetInputConnection(tube.GetOutputPort())

tube_actor = vtk.vtkActor()
tube_actor.SetMapper(tube_mapper)
tube_actor.SetTexture(texture)

renderer.AddActor(tube_actor)

render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
style = vtk.vtkInteractorStyleTrackballCamera()
interactor.SetInteractorStyle(style)
interactor.SetRenderWindow(render_window)
renderer.SetBackground(1, 1, 1)
renderer.ResetCamera()
renderer.GetActiveCamera().Zoom(3)

render_window.Render()
interactor.Start()

```

Any thoughts on the cause of this?
