# Compute Shader Bind Two Textures

**URL:** <https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799>\
**Category:** Questions\
**Tags:** webgpu, compute-shader\
**Created:** [July 29, 2025, 12:49pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799 "2025-07-29T12:49:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdurnin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rdurnin/32/11381_2.png) [@rdurnin](https://forum.babylonjs.com/u/rdurnin)\
**Post date:** [July 29, 2025, 12:49pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799/1 "2025-07-29T12:49:14Z")

</div>

Hello, and I have been working on some compute shader tools and am running into an issue with binding more than one input texture and sampler. The issue arises when I try to setTexture on the instanced shader, and the message states that there are mismatched expected to included bindings.

I have managed to recreate a similar failure in the following [PG](https://playground.babylonjs.com/#75L1VF), although it is likely I am misunderstanding or missing an example ([resource](https://doc.babylonjs.com/features/featuresDeepDive/materials/shaders/computeShader#shader-language-and-input-bindings))

Thanks for any help,  
r

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 29, 2025, 2:48pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799/2 "2025-07-29T14:48:59Z")

</div>

cc @Evgeni_Popov (please be patient as he is on vacations :))

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 29, 2025, 6:47pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799/3 "2025-07-29T18:47:22Z")

</div>

Parameters that you declare in the shader (like `deux` and `samplerDeux`) but don’t use in the code are automatically removed at compilation time. So, you should not declare them:

> **[Babylon.js Playground](https://playground.babylonjs.com/#75L1VF%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

You can also use the [Phony assignment](https://gpuweb.github.io/gpuweb/wgsl/#phony-assignment-section) if you want to keep the declaration:

> **[Babylon.js Playground](https://playground.babylonjs.com/#75L1VF%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![rdurnin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/rdurnin/32/11381_2.png) [@rdurnin](https://forum.babylonjs.com/u/rdurnin)\
**Post date:** [July 29, 2025, 9:37pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799/4 "2025-07-29T21:37:32Z")

</div>

Thanks, and understood. I had a list of textures which were being conditionally sampled and, without being able to use pre-processor macros, I was wrapping them in ifs. The compiler was pruning them and it was causing the mismatch.

Enjoy your vacation, and thanks again.

r
