Problem with CustomProceduralTexture method limiting the number of input Rendertarget

I am using the “new BABYLON.CustomProceduralTexture” method to process images (rendertarget) and have assigned a shader to it.

The problem is: after inputting 30 images, the shader doesn’t seem to be able to fully utilize (texture2D) them.

The result is that I can only texture2D 16 RTs (up to RT15, at which point the proceduraltexture output is correct),as the figure below:

But when I add: totalColor += texture2D(RT16, vUV).rgb;, the output is wrong:

How can I fix this so that I can use all 30 input RTs in the shader?

Playground Proj here: Customprocedualtexture problem | Babylon.js Playground (babylonjs.com)

thank you very much!!!

There’s a maximum number of textures you can use in a fragment shader, that you can query from engine.getCaps().maxTexturesImageUnits. It’s generally 16, but it may depend on your GPU.

Thanks for the reply, can I increase the maximum value by modifying the code? Or is this entirely a hardware limitation (GPU) and we can’t modify this maximum value at all?

No, it’s a hardware limitation, you can’t do anything about it.

What you could do is merge several textures into a single one, to lower the number of texture units used in the fragment shader.

ok,got it,thank you so much :+1: