# How to access vtkTexture in vtk shader?

**URL:** https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678
**Category:** Support
**Created:** [February 14, 2023, 3:38pm UTC](https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678 "2023-02-14T15:38:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Reshma\_R\_S](https://discourse.vtk.org/user_avatar/discourse.vtk.org/reshma_r_s/32/6187_2.png) [@Reshma\_R\_S](https://discourse.vtk.org/u/Reshma_R_S)
#### Post date: [February 14, 2023, 3:38pm UTC](https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678/1 "2023-02-14T15:38:42Z")

</div>

I have used the tutorial [Shaders In VTK - KitwarePublic](https://vtk.org/Wiki/Shaders_In_VTK) to implement a basic shader in my python vtk program. I know that we can create a texture by using vtk.vtkTexture() class, but I don’t know how I can pass or use that in the shader. Can anyone provide some high-level comments to help on this? Thanks!

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 14, 2023, 9:44pm UTC](https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678/2 "2023-02-14T21:44:06Z")

</div>

Hello,

What are you trying to achieve?

best,

Paulo

---

<div class="post-metadata">

### Author: ![Reshma\_R\_S](https://discourse.vtk.org/user_avatar/discourse.vtk.org/reshma_r_s/32/6187_2.png) [@Reshma\_R\_S](https://discourse.vtk.org/u/Reshma_R_S)
#### Post date: [February 15, 2023, 11:14am UTC](https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678/3 "2023-02-15T11:14:17Z")

</div>

Instead of rendering a point cloud data as mere points on the scene. I wanted to replace every point with a small patch of transparent PNG image. For that, I am trying to pass a texture image from the main python program to the vtk shaders. In C++ I would do the following to define the textures, but in my python program, I dont know how I can do this. Can I use PyOpenGL to initialize the texture images and then use it in vtk shaders? Will that work?

```auto
unsigned int texture;
glGenTextures(1, &texture);  
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 15, 2023, 11:55am UTC](https://discourse.vtk.org/t/how-to-access-vtktexture-in-vtk-shader/10678/4 "2023-02-15T11:55:48Z")

</div>

My two cents: since we refer a texture (which resides in the graphics card) by its ID I see no problem in porting that to Python. Give it a try. See what happens.
