# Compute shader with texture input

**URL:** https://discourse.libcinder.org/t/compute-shader-with-texture-input/1962
**Category:** Using Cinder
**Created:** [March 16, 2022, 11:45am UTC](https://discourse.libcinder.org/t/compute-shader-with-texture-input/1962 "2022-03-16T11:45:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![totalgee](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/totalgee/32/274_2.png) [@totalgee](https://discourse.libcinder.org/u/totalgee)
#### Post date: [March 16, 2022, 11:45am UTC](https://discourse.libcinder.org/t/compute-shader-with-texture-input/1962/1 "2022-03-16T11:45:10Z")

</div>

Hi there, I’m having trouble with a compute shader (for particles) where I want to use a texture as input. I’ve tried binding a regular texture and using `uniform sampler2D uTex` and reading with `texture(uTex, uv)`. I also tried declaring the uniform using `layout(binding = 1, rgba8) uniform readonly image2D uTex` and reading data using `imageLoad(uTex, ivec2(imageSize(uTex) * uv))` (my `uv` is from 0 to 1), with no luck, I’m always getting black pixels. (note that for the second case, I had to add a GL\_IMAGE\_2D case to `checkUniformType()`, as mentioned in [this thread](https://discourse.libcinder.org/t/writing-to-a-texture-via-compute-shaders/751), so that the uniform setting call doesn’t fail when I pass it texture unit 1. (I’m also activating the appropriate texture unit and binding my texture before running the compute shader)

Has anybody got something similar working (image input to a compute shader in Cinder)?

---

<div class="post-metadata">

### Author: ![totalgee](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/totalgee/32/274_2.png) [@totalgee](https://discourse.libcinder.org/u/totalgee)
#### Post date: [March 16, 2022, 8:38pm UTC](https://discourse.libcinder.org/t/compute-shader-with-texture-input/1962/2 "2022-03-16T20:38:56Z")

</div>

Never mind, it was user error. I was setting the texture incorrectly, after all. It does work with `sampler2D` and calling `texture()` just fine from the compute shader…phew!
