0

I need to pass an array of vectors as a uniform to a shader. As far as I understood code should be as follows:

fragment_shader = """

    uniform int myVectorSize;
    uniform vec4 myVector[50];

    void main() {
      gl_FragColor = ... // using myVector    
    }
"""

But I did not find a way to pass this vector to the shader:

material = ShaderMaterial(
    uniforms=dict(
        myVectorSize=(dict(value=10),
        myVector=???,
        **UniformsLib['common']
    ),
    fragmentShader=fragment_shader,
)

Is there a way to do this?

LJᛃ
  • 7,655
  • 2
  • 24
  • 35
  • I've never had to pass a vector larger than 4, but have you tried passing an array as the vector's value? `uniforms: {myVector: {value: [1, 1, 1, 1, 1, 1, 1, 1, ..., 1] } }`? – M - Nov 18 '21 at 21:54
  • thank you, it really works – Leo Abalckin Nov 19 '21 at 06:49

0 Answers0