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.

1 Like

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

@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.

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:

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

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

1 Like