Problem with using two textures in WGSL post-processing

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

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.

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.

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:

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:

2 Likes