# How to add texture coordinates to an XML VTK File?

**URL:** https://discourse.vtk.org/t/how-to-add-texture-coordinates-to-an-xml-vtk-file/5999
**Category:** Support
**Created:** [June 14, 2021, 11:22pm UTC](https://discourse.vtk.org/t/how-to-add-texture-coordinates-to-an-xml-vtk-file/5999 "2021-06-14T23:22:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![datathing](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/e8c25b/32.png) [@datathing](https://discourse.vtk.org/u/datathing)
#### Post date: [June 14, 2021, 11:22pm UTC](https://discourse.vtk.org/t/how-to-add-texture-coordinates-to-an-xml-vtk-file/5999/1 "2021-06-14T23:22:07Z")

</div>

Hi, I haven’t been able to find any information on how to do this. I want to be able to add texture coordinates to .vtu file. A simple example being the following shape:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/c/c359800cde596bd024a24772643bfa206aa2a59a.png)  
…which is defined by the following .vtu in XML format:

```auto
<?xml version="1.0"?>
<VTKFile version="0.1" type="UnstructuredGrid">
  <UnstructuredGrid>
    <Piece NumberOfPoints="32" NumberOfCells="4">
      <Points>
        <DataArray type="Float64" Name="points" NumberOfComponents="3" format="ascii">
          0.0 1.0 99.0 1.0 1.0 99.0 0.0 2.0 99.0 1.0 2.0 99.0 0.0 1.0 100.0 1.0 1.0 100.5 0.0 2.0 100.0 1.0 2.0 100.5
          1.0 1.0 99.0 2.0 1.0 99.0 1.0 2.0 99.0 2.0 2.0 99.0 1.0 1.0 100.5 2.0 1.0 101.0 1.0 2.0 100.5 2.0 2.0 101.0
          0.0 0.0 99.0 1.0 0.0 99.0 0.0 1.0 99.0 1.0 1.0 99.0 0.0 0.0 100.0 1.0 0.0 100.5 0.0 1.0 100.0 1.0 1.0 100.5
          1.0 0.0 99.0 2.0 0.0 99.0 1.0 1.0 99.0 2.0 1.0 99.0 1.0 0.0 100.5 2.0 0.0 101.0 1.0 1.0 100.5 2.0 1.0 101.0
        </DataArray>
      </Points>
      <Cells>
        <DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="ascii">
          0 1 2 3 4 5 6 7
          8 9 10 11 12 13 14 15
          16 17 18 19 20 21 22 23
          24 25 26 27 28 29 30 31
        </DataArray>
        <DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="ascii">
          8
          16
          24
          32
        </DataArray>
        <DataArray type="UInt8" Name="types" NumberOfComponents="1" format="ascii">
          11
          11
          11
          11
        </DataArray>
      </Cells>
      <CellData>
        <DataArray type="Float64" Name="top" NumberOfComponents="1" format="ascii">
          100.0 101.0 100.0 101.0
        </DataArray>
        <DataArray type="Float64" Name="botm" NumberOfComponents="1" format="ascii">
          99.0 99.0 99.0 99.0
        </DataArray>
        <DataArray type="Float64" Name="idomain" NumberOfComponents="1" format="ascii">
          1.0 1.0 1.0 1.0
        </DataArray>
      </CellData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

```

However, I when I visualise this in ParaView it tells me:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/7/7eecff58f95111c24031946153282bb636c290b7.png)

Is it possible to add the tcoords to the .vtu file so that I apply a texture to the top surface something like this:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/198263e5aa0b7ea46cdbd222a31fd7e6f5efc4b7.jpeg)

I know that if I have a plane and use the texture coordinates to plan filter that I can get a texture rendered that way, but I would like to apply it to a specific surface on a 3D shape. Using the texture coord to plane filter on a 3D shape just results in the texture being stretched all round the edges and rendered on all sides.

---

<div class="post-metadata">

### Author: ![Yohann\_Bearzi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yohann_bearzi/32/671_2.png) [@Yohann\_Bearzi](https://discourse.vtk.org/u/Yohann_Bearzi)
#### Post date: [June 15, 2021, 12:23pm UTC](https://discourse.vtk.org/t/how-to-add-texture-coordinates-to-an-xml-vtk-file/5999/2 "2021-06-15T12:23:38Z")

</div>

I think that you need to set `NumberOfComponents="2"` so an array can be used as texture coordinates.

---

<div class="post-metadata">

### Author: ![datathing](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/e8c25b/32.png) [@datathing](https://discourse.vtk.org/u/datathing)
#### Post date: [June 23, 2021, 8:27pm UTC](https://discourse.vtk.org/t/how-to-add-texture-coordinates-to-an-xml-vtk-file/5999/3 "2021-06-23T20:27:53Z")

</div>

Thanks!
