# Using set\_texture with sampler2D textures?

**URL:** <https://forum.defold.com/t/using-set-texture-with-sampler2d-textures/77489>\
**Category:** Questions\
**Created:** [July 18, 2024, 4:12am UTC](https://forum.defold.com/t/using-set-texture-with-sampler2d-textures/77489 "2024-07-18T04:12:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rawktron](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/rawktron/32/22786_2.png) [@rawktron](https://forum.defold.com/u/rawktron)\
**Post date:** [July 18, 2024, 4:12am UTC](https://forum.defold.com/t/using-set-texture-with-sampler2d-textures/77489/1 "2024-07-18T04:12:10Z")

</div>

Hey folks – is there a way to use set\_texture for textures that are used as sampler2D in a shader (ie. not rendered but used as like lookups)? It seems like it should be possible but couldn’t find any info on it. Thanks!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 18, 2024, 5:50am UTC](https://forum.defold.com/t/using-set-texture-with-sampler2d-textures/77489/2 "2024-07-18T05:50:27Z")

</div>

> [@rawktron](#):
>
> is there a way to use set\_texture for textures that are used as sampler2D in a shader (ie. not rendered but used as like lookups)?

I think what you are asking for is how to use a texture from somewhere in your game as a render target? We have a concept of texture handles which uniquely identifies a texture so that you can pass it from your game to your render script and vice versa:

> **[Texture handles - The render pipeline in Defold](https://defold.com/manuals/render/#texture-handles)**
>
> Every object that is shown on screen by the engine: sprites, models, tiles, particles or GUI nodes, are drawn by a renderer. At the heart of the renderer is a render script that controls the render pipeline. By default, every 2D object is drawn with...

---

<div class="post-metadata">

**Author:** ![rawktron](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/rawktron/32/22786_2.png) [@rawktron](https://forum.defold.com/u/rawktron)\
**Post date:** [July 19, 2024, 6:31pm UTC](https://forum.defold.com/t/using-set-texture-with-sampler2d-textures/77489/3 "2024-07-19T18:31:44Z")

</div>

Ok – that helped wrt texture handles and there were some good examples in there. Something that caught me out though was that it seems like, no matter what, you have to use those texture handles and call `enable_texture` even for textures you set in the editor on materials? I found that my shader couldn’t read from anything set in the editor, but if I manually did a `create_texture`, pass in its handle and `enable_texture` that it worked as expected. I probably was doing something wrong, but I expected things assigned in the editor window to be available in the shaders.
