# How bind texture to a sampler?

**URL:** https://discourse.vtk.org/t/how-bind-texture-to-a-sampler/4709
**Category:** Support
**Created:** [November 21, 2020, 7:48am UTC](https://discourse.vtk.org/t/how-bind-texture-to-a-sampler/4709 "2020-11-21T07:48:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jone7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/e36b37/32.png) [@Jone7](https://discourse.vtk.org/u/Jone7)
#### Post date: [November 21, 2020, 7:48am UTC](https://discourse.vtk.org/t/how-bind-texture-to-a-sampler/4709/1 "2020-11-21T07:48:57Z")

</div>

I use AddFragmentShaderReplacement for fragment shader added “uniform sampler2D s”, Can someone tell me how to bind a texture to “sampler2D s” in VTK?

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [November 22, 2020, 1:35pm UTC](https://discourse.vtk.org/t/how-bind-texture-to-a-sampler/4709/2 "2020-11-22T13:35:50Z")

</div>

See TestMultiTexturing.cxx for an example. To bind the texture use

actor-\>GetProperty()-\>SetTexture(“skyclouds”, tex2);

that will cause the texture to be bound/activated and then unbound/deactivated when that actor is rendered.

---

<div class="post-metadata">

### Author: ![Jone7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/e36b37/32.png) [@Jone7](https://discourse.vtk.org/u/Jone7)
#### Post date: [November 23, 2020, 2:32am UTC](https://discourse.vtk.org/t/how-bind-texture-to-a-sampler/4709/3 "2020-11-23T02:32:46Z")

</div>

Thank you Ken,your answer solved my problem perfectly!
