How can i set an int or ivec array to a uniform variable in shader?

Hi.
I’m trying to figure out how to set int array or ivec array to shader.
I’m using ShaderMaterial to set up my shader. There are setArray methods on ShaderMaterial but they seems to me to work only with floats:
https://playground.babylonjs.com/#4LDXG1#8
Am i doing something wrong?

There are setIntArray methods thet are look like do the stuff i need in Effect and Engine classes, but i can’t figure out can i use them and how.

Also i found request to add missing methods to ShaderMaterial Add missing setXXX methods in ShaderMaterial
But it seems thet only setMatrices method was added.

Thanks in advanse

Welcome aboard!

The IntArrayXXX methods from the Effect are not available directly through the ShaderMaterial class, but you can bind the data yourself on the onBindObservable event:

https://playground.babylonjs.com/#4LDXG1#10

A PR is welcome if you want to add the missing methods to the ShaderMaterial class!

Evgeni, thank you very much for your reply.
At the same time, it became clear how to use the getEffect method in the ShaderMaterial)

Regarding the pool request, I would love to, but I don’t yet understand how exactly the methods for setting variables in ShaderMaterial work. The only thing that happens in the setXXX methods is call of _checkUniform and setting the value passed to the method into a private variable of the class. Or I don’t have to understand what’s going on under the hood and just add methods that will set values of the correct type like Int32Array to _vectorsX Arrays?

Yes, you should do the same thing in new methods like setIntArray2, setIntArray3, etc and then update the ShaderMaterial.bind method accordingly: that’s where the values are really passed to the engine by calling the corresponding effect.setXXX methods.