# Problem with using two textures in WGSL post-processing

**URL:** <https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831>\
**Category:** Questions\
**Created:** [October 11, 2023, 4:12pm UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831 "2023-10-11T16:12:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://forum.babylonjs.com/u/christian)\
**Post date:** [October 11, 2023, 4:12pm UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/1 "2023-10-11T16:12:21Z")

</div>

I followed this example to create a trivial post-processing pixel shader.

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%237)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

However, I noticed that if I change the names of the texture or sampler at all, I get a binding error. It seems like Babylon is using static names to bind the texture and sampler.

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

The problem with this is that it’s not clear how to pass another texture and sampler to the shader. I’m not sure if this is a bug or I am just doing something wrong.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 12, 2023, 12:30am UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/2 "2023-10-12T00:30:48Z")

</div>

Assigned @Evgeni\_Popov on October 12, 2023, 12:30am UTC



---

<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:** [October 12, 2023, 9:14am UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/3 "2023-10-12T09:14:21Z")

</div>

You must declare the name of the texture in the `samplers` parameter of the `PostProcess` constructor. Also, you must bind the texture as well as the texture sampler:

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%2311)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Note that if you have “sampler” in the name of your texture, the system will assume that you will handle the texture sampler yourself (by calling `setTextureSampler`), but if you don’t, it will do it automatically:

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%2312)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<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:** [October 12, 2023, 9:14am UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/4 "2023-10-12T09:14:29Z")

</div>

Unassigned @Evgeni\_Popov on October 12, 2023, 9:14am UTC



---

<div class="post-metadata">

**Author:** ![Eric.J](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/eric.j/32/34502_2.png) [@Eric.J](https://forum.babylonjs.com/u/Eric.J)\
**Post date:** [July 9, 2024, 1:53am UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/5 "2024-07-09T01:53:53Z")

</div>

@Evgeni_Popov  
There seems to be a compatibility issue here when the Playground version is 7.x.0, which works fine with version 6.x.

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%2311)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/4/4408fbbef8f0a9f07d79c956f566e9239ee6e976.png)

I want to use custom “TextureSampler” with different property. Then I looked into the source code of 7.x.0 and changed the code like this:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/b/4b0306d9e71953050c494a737e98b5cf078c2975.png)

> **[Babylon.js Playground](https://playground.babylonjs.com/?webgpu#8BHKCQ%2343)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

It works in 7.x.0 but will get an error in 6.x.0. Are the two versions incompatible?

---

<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 10, 2024, 10:15am UTC](https://forum.babylonjs.com/t/problem-with-using-two-textures-in-wgsl-post-processing/44831/6 "2024-07-10T10:15:45Z")

</div>

`setTextureSampler` has been removed from the `Effect` object (I think because of packaging problems), so it’s the only way to do it now.
